Advertisement
Guest User

Untitled

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