Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace cookingAPI;
- require_once('config.php');
- $f3 = require_once('lib/base.php');
- $db = new DB\SQL(
- 'mysql:host='.DB_HOST.';port=3306;dbname='.DB_NAME,
- DB_USER,
- DB_PASS
- );
- $user = new DB\SQL\Mapper($db,'users');
- $recipe = new DB\SQL\Mapper($db,'recipes');
- $ingredient = new DB\SQL\Mapper($db,'ingredients');
- $f3->set('DB', $db);
- $f3->route('GET /',
- function() {
- echo 'Hello, World!';
- }
- );
- $f3->route('GET /user',
- function() {
- echo 'All users';
- }
- );
- $f3->route('GET /user/@id',
- function($f3) {
- echo 'user #'.$f3->get('PARAMS.id');
- }
- );
- $f3->route('GET /recipe',
- function() {
- echo 'All recipes';
- }
- );
- $f3->route('GET /recipe/@id',
- function($f3) {
- echo 'Recipe #'.$f3->get('PARAMS.id');
- }
- );
- $f3->route('GET /ingredient',
- function() {
- echo 'All ingredients';
- }
- );
- $f3->route('GET /ingredient',
- function($f3) {
- echo 'Ingredient #'.$f3->get('PARAMS.id');
- }
- );
- $f3->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement