Modified Silex to allow Controllers, Models and DAOs using an Autoloader.
For this example to actually run you'll need to set up a MySQL instance with:
DB Stuff
-
Make a schema named 'test_schema'
-
Make a table under 'test_schema' named automobiles
Cols:
- id INT(11) PK, NN, AI
- type VARCHAR(45)
- number_of_wheels VARCHAR(45)
- color VARCHAR(45)
- make VARCHAR(45)
- model VARCHAR(45)
- Make a table under 'test_schema' named users
Cols:
- id INT(11) PK, NN, AI
- first_name VARCHAR(45)
- last_name VARCHAR(45)
- dob VARCHAR(45)
- phone_num VARCHAR(45)
- Populate both tables with some information
Code Stuff
- Pull down code somewhere PHP can run
- Run Composer
- Add correct configs info in configs/config.php for MySQL instance
Using POSTMAN or in a browser go to:
http://YOUR_URL/api/v2/test if working you should see a message telling you the API is working
If you get this running and would like to mess around with it. Try adding a 'get Automobile by model' and/or a 'create a new Automobile' endpoint