Advertisement
Guest User

Untitled

a guest
Nov 19th, 2015
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. namespace cookingAPI;
  4.  
  5. require_once('config.php');
  6. $f3 = require_once('lib/base.php');
  7.  
  8. $db = new DB\SQL(
  9.     'mysql:host='.DB_HOST.';port=3306;dbname='.DB_NAME,
  10.     DB_USER,
  11.     DB_PASS
  12.     );
  13. $user = new DB\SQL\Mapper($db,'users');
  14. $recipe = new DB\SQL\Mapper($db,'recipes');
  15. $ingredient = new DB\SQL\Mapper($db,'ingredients');
  16.  
  17. $f3->set('DB', $db);
  18. $f3->route('GET /',
  19.         function() {
  20.             echo 'Hello, World!';
  21.         }
  22.     );
  23. $f3->route('GET /user',
  24.         function() {
  25.             echo 'All users';
  26.         }
  27.     );
  28. $f3->route('GET /user/@id',
  29.         function($f3) {
  30.             echo 'user #'.$f3->get('PARAMS.id');
  31.         }
  32.     );
  33. $f3->route('GET /recipe',
  34.         function() {
  35.             echo 'All recipes';
  36.         }
  37.     );
  38. $f3->route('GET /recipe/@id',
  39.         function($f3) {
  40.             echo 'Recipe #'.$f3->get('PARAMS.id');
  41.         }
  42.     );
  43. $f3->route('GET /ingredient',
  44.         function() {
  45.             echo 'All ingredients';
  46.         }
  47.     );
  48. $f3->route('GET /ingredient',
  49.         function($f3) {
  50.             echo 'Ingredient #'.$f3->get('PARAMS.id');
  51.         }
  52.     );
  53.  
  54.  
  55. $f3->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement