Restful architecture for silex php framework and resources being used as another api from heroku.
-
API resource: herokuApp
-
Install step by step, can be seen here
RESTful architecure simplifies the routes for given resources for ex: users
CRUD operations performed on the users resources by defining the following routes in ./index.php
.
Silex provides the smooth way to do this.
Need routes:
METHOD[action] url GET localhost/ GET[index] localhost/users GET[new] localhost/users/new POST[create] localhost/users GET[show] localhost/users/{id} GET[edit] localhost/users/{id}/edit PUT[update] localhost/users/{id} DELETE[destroy] localhost/users/{id}
Silex framework style:
Sample: $app->get('/', function (Silex\Application $app) { return "String or Collection" or "render some page"; }); REST routes can be found in <code>./index.php</code>
* Run apache2 $ sudo service apache2 start if nginx runnning default stop using $sudo service nginx stop
Open in your browser.
-
A sample app for Silex how to build REST routes and integration with API.
Can be found here
-
Stackoverflow