Skip to content

Commit dd43dfa

Browse files
Merge conflict resolved
2 parents 42ac9cf + 130d2ad commit dd43dfa

25 files changed

+981
-148
lines changed

README.md

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,105 @@
1-
authOauth
2-
=========
1+
# A Sample Symfony 2 RESTful API Project with FOSUserBundle + FOSRestBundle + FOSOauthServerBundle for Mobile and Web Clients
32

4-
A Symfony project created on January 20, 2017, 2:52 pm.
3+
This is an example project, ready to use. This project is using below Symfony Bundles:
54

6-
[Read Installtion and Usage](myReadMe.md)
5+
* [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle)
6+
* [FOSRestBundle](https://github.com/FriendsOfSymfony/FOSRestBundle)
7+
* [FOSOAuthServerBundle](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle)
8+
* [JMSSerializerBundle](https://github.com/schmittjoh/JMSSerializerBundle)
9+
* [NelmioApiDocBundle](http://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html)
10+
* [AsseticBundle](https://github.com/symfony/assetic-bundle)
11+
12+
## Installation Steps:
13+
14+
**Step 0:**
15+
16+
Below environment is required:
17+
Linux
18+
=====
19+
- PHP 5.6
20+
- MySql (though other DB can also be used with a little change in the configuration)
21+
- Apache2 (alternatively, local PHP dev server can also be used for testing purpose)
22+
- Composer
23+
- Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command)
24+
25+
Windows
26+
=======
27+
- MAMP
28+
- Composer
29+
- Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command)
30+
31+
Mac
32+
===
33+
- MAMP
34+
- Composer
35+
- Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command)
36+
37+
**Step 1 - Clone the project:**
38+
39+
Git clone this project from Github to a web folder, say auth, via
40+
git clone .... auth
41+
42+
and run
43+
cd /path/to/auth
44+
composer install
45+
46+
**Step 2 - Create Database tables**
47+
48+
cd /path/to/auth
49+
php app/console doctrine:database:create
50+
php app/console doctrine:scheme:create
51+
52+
**Step 3 - Create assets**
53+
54+
cd /path/to/auth
55+
php app/console assets:install
56+
php app/console assetic:dump
57+
58+
**Step 4 - Create an Admin user**
59+
60+
cd /path/to/auth
61+
php app/console fos:user:create admin [email protected] password
62+
63+
Make this user admin
64+
65+
php app/console fos:user:create admin ROLE_ADMIN
66+
67+
Now you are ready to use the Package!
68+
69+
## Use this Package
70+
71+
1. Test API
72+
2. Use API via a Mobile Client
73+
3. Backend Administration
74+
75+
You will need to start the server before you can use this package:
76+
77+
cd /path/to/auth
78+
php app/console server:run
79+
80+
#### 1. Test API
81+
82+
You can test the provided API via curl or Postman. Here we provide as to how to use Postman.
83+
84+
**API documentation is available, via NelmioApiDocBundle, at http://127.0.0.1:800/api/doc.**
85+
86+
* We have provide sample Postman Collections. Please import any of the Collection to Postman.
87+
* Open the imported Collection and start executing the contained links one by one. For your convenience, we have arranged the links in the preferred order of execution.
88+
* You may start with create the client via API or you will have to use client_id and client_secret of the client created above via command line.
89+
90+
91+
#### 2. Use API via a Mobile Client
92+
93+
Separate sample Github repos are available for iPhone and Android Mobile Clients which use APIs provided by this repo.
94+
95+
iPhone:
96+
Android:
97+
98+
#### 3. Backend Administration
99+
100+
In a browser, goto the package site by http://127.0.0.1:8000. This is the Backend Administration tool and can be plugged into any User App easily. It is a simple page. The options are self explanatory.
101+
102+
The salient features of the Backend are:
103+
* The Backend is internationalization enabled. It currently supports English, French and Hindi.
104+
* Options have been provided to pick desired front-end theme for the Backend. The choices available are - Bootstrap, Materialize and Skeleton. **To change the theme, modify key "fronend_theme" in parameters.yml accordingly.** However, the design is open-ended and you may add your preferred theme easily. Please also note that theming has only been provided for base and nav. Other top level stuff is using bootstrap, you can theme as per your choice using base theme.
105+
* The Web user management pages are coming directly from FOSUserBundle views. You may override these pages, per your need.

app/Resources/views/base.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
bootstrap, material and skeleton. Just change the below line to select the other desired
55
theme.
66
#}
7-
{% extends 'base_bootstrap.html.twig' %}
7+
{% extends "base_#{frontend_theme}.html.twig" %}

app/Resources/views/nav_bootstrap.html.twig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@
3939
<li class="dropdown">
4040
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ 'action.admin_menu'|trans }}<span class="caret"></span></a>
4141
<ul class="dropdown-menu locales" role="menu" aria-labelledby="locales">
42-
<li><a href="#">{{ 'action.role_management'|trans }}</a></li>
43-
<li><a href="#">{{ 'action.user_management'|trans }}</a></li>
42+
<li><a href="{{ path('admin_user_index') }}">{{ 'action.user_management'|trans }}</a></li>
4443
<li><a href="{{ path('admin_client_index') }}">{{ 'action.client_management'|trans }}</a></li>
45-
<li><a href="{{ path('admin_client_new') }}">{{ 'action.create_new_client'|trans }}</a></li>
4644
</ul>
4745
</li>
4846
{% endif %}

app/Resources/views/nav_materialize.html.twig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
<li>
3232
<a href="#">{{ 'action.admin_menu'|trans }}<span></span></a>
3333
<ul>
34-
<li><a href="#">{{ 'action.role_management'|trans }}</a></li>
35-
<li><a href="#">{{ 'action.user_management'|trans }}</a></li>
34+
<li><a href="{{ path('admin_user_index') }}">{{ 'action.user_management'|trans }}</a></li>
3635
<li><a href="{{ path('admin_client_index') }}">{{ 'action.client_management'|trans }}</a></li>
37-
<li><a href="{{ path('admin_client_new') }}">{{ 'action.create_new_client'|trans }}</a></li>
3836
</ul>
3937
</li>
4038
{% endif %}

app/Resources/views/nav_skeleton.html.twig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
<li>
3232
<a href="#">{{ 'action.admin_menu'|trans }}<span></span></a>
3333
<ul>
34-
<li><a href="#">{{ 'action.role_management'|trans }}</a></li>
35-
<li><a href="#">{{ 'action.user_management'|trans }}</a></li>
34+
<li><a href="{{ path('admin_user_index') }}">{{ 'action.user_management'|trans }}</a></li>
3635
<li><a href="{{ path('admin_client_index') }}">{{ 'action.client_management'|trans }}</a></li>
37-
<li><a href="{{ path('admin_client_new') }}">{{ 'action.create_new_client'|trans }}</a></li>
3836
</ul>
3937
</li>
4038
{% endif %}

app/config/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ framework:
3737
twig:
3838
debug: "%kernel.debug%"
3939
strict_variables: "%kernel.debug%"
40-
40+
globals:
41+
frontend_theme: "%frontend_theme%"
42+
4143
# Doctrine Configuration
4244
doctrine:
4345
dbal:

src/ApiBundle/Controller/Admin/ClientController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ApiBundle\Controller\Admin;
44

55
use ApiBundle\Entity\Client;
6-
use ApiBundle\Form\ClientType;
6+
77
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
88
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
99
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -60,7 +60,6 @@ public function newAction(Request $request)
6060
->add('name', 'text', array('label' => 'label.client_name', 'data' => $clientName ))
6161
->add('redirect_url', 'text', array('label' => 'label.admin_redirecturl', 'data' => $redirectUrl ))
6262
->add('password', 'password', array('label' => 'label.admin_password' ))
63-
->add('send', 'submit', array('label' => 'label.create_client' ))
6463
->getForm();
6564
$form->handleRequest($request);
6665

0 commit comments

Comments
 (0)