|
1 |
| -authOauth |
2 |
| -========= |
| 1 | +# A Sample Symfony 2 RESTful API Project with FOSUserBundle + FOSRestBundle + FOSOauthServerBundle for Mobile and Web Clients |
3 | 2 |
|
4 |
| -A Symfony project created on January 20, 2017, 2:52 pm. |
| 3 | +This is an example project, ready to use. |
5 | 4 |
|
6 |
| -[Read Installtion and Usage](myReadMe.md) |
| 5 | +## Installation Steps: |
| 6 | + |
| 7 | +**Step 0:** |
| 8 | + |
| 9 | + Below environment is required: |
| 10 | + Linux |
| 11 | + ===== |
| 12 | + - PHP 5.6 |
| 13 | + - MySql (though other DB can also be used with a little change in the configuration) |
| 14 | + - Apache2 (alternatively, local PHP dev server can also be used for testing purpose) |
| 15 | + - Composer |
| 16 | + - Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command) |
| 17 | + |
| 18 | + Windows |
| 19 | + ======= |
| 20 | + - MAMP |
| 21 | + - Composer |
| 22 | + - Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command) |
| 23 | + |
| 24 | + Mac |
| 25 | + === |
| 26 | + - MAMP |
| 27 | + - Composer |
| 28 | + - Chrome browser with Postman plugin or separate Postman installation to test the API (though API can also be tested via "curl" command) |
| 29 | + |
| 30 | +**Step 1 - Clone the project:** |
| 31 | + |
| 32 | + Git clone this project from Github to a web folder, say auth, via |
| 33 | + git clone .... auth |
| 34 | + |
| 35 | + and run |
| 36 | + cd /path/to/auth |
| 37 | + composer install |
| 38 | + |
| 39 | +**Step 2 - Create Database tables** |
| 40 | + |
| 41 | + cd /path/to/auth |
| 42 | + php app/console doctrine:database:create |
| 43 | + php app/console doctrine:scheme:create |
| 44 | + |
| 45 | +**Step 3 - Create assets** |
| 46 | + |
| 47 | + cd /path/to/auth |
| 48 | + php app/console assets:install |
| 49 | + php app/console assetic:dump |
| 50 | + |
| 51 | +**Step 4 - Create an Admin user** |
| 52 | + |
| 53 | + cd /path/to/auth |
| 54 | + php app/console fos:user:create admin [email protected] password |
| 55 | + |
| 56 | + Make this user admin |
| 57 | + |
| 58 | + cd /path/to/auth |
| 59 | + php app/console fos:user:create admin ROLE_ADMIN |
| 60 | + |
| 61 | +**Step 5 - Create an OAuth2 Client via command line** |
| 62 | + |
| 63 | + |
| 64 | + cd /path/to/auth |
| 65 | + php app/console aoa:oauth-server:client:create --redirect-uri="http://127.0.0.1:8000/" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials" |
| 66 | + |
| 67 | + You will get an output like this: |
| 68 | + |
| 69 | + `{ |
| 70 | + "client_id": "1_1uilrhl1w2rokgg88kg8s0wswogwsggw0044cwc04k8s0oc4sg", |
| 71 | + "client_secret": "4g723vbss7i8kc88swok0s4wk4ck4c0w8gc8g4gwwwowsc0owc" |
| 72 | + }` |
| 73 | + |
| 74 | +Now you are ready to use the Package! |
| 75 | + |
| 76 | +## Use this Package |
| 77 | + |
| 78 | + |
| 79 | +1. Test API |
| 80 | +2. Use API via a Mobile Client |
| 81 | +3. Backend Administration |
| 82 | + |
| 83 | +You will need to start the server before you can use this package: |
| 84 | + |
| 85 | + cd /path/to/auth |
| 86 | + php app/console server:run |
| 87 | + |
| 88 | +#### 1. Test API |
| 89 | + |
| 90 | +You can test the provided API via curl or Postman. Here we provide as to how to use Postman. |
| 91 | + |
| 92 | +* We have provide sample Postman Collections. Please import any of the Collection to Postman. |
| 93 | +* 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. |
| 94 | +* 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. |
| 95 | + |
| 96 | + |
| 97 | +#### 2. Use API via a Mobile Client |
| 98 | + |
| 99 | +Separate sample Github repos are available for iPhone and Android Mobile Clients which use APIs provided by this repo. |
| 100 | + |
| 101 | + iPhone: |
| 102 | + Android: |
| 103 | + |
| 104 | +#### 3. Backend Administration |
| 105 | + |
| 106 | +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. |
| 107 | + |
| 108 | +The salient features of the Backend are: |
| 109 | +* The Backend is internationalization enabled. It currently supports English, French and Hindi. |
| 110 | +* Options have been provided to pick desired front-end theme for the Backend. The choices available are - Bootstrap, Materialize and Skeleton. However, the design is open-ended and you may add your preferred theme easily. |
| 111 | +* The Web user management pages are coming directly from FOSUserBundle views. You may override these pages, per your need. |
0 commit comments