Advertisement
Guest User

Untitled

a guest
May 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. require '../vendor/autoload.php';
  3. require '../src/models/User.php';
  4.  
  5. $config = include('../src/config.php');
  6. $app = new SlimApp(['settings']=>$config);
  7. $container = $app->getContainer();
  8.  
  9. $capsule = new IlluminateDatabaseCapsuleManager;
  10. $capsule->addConnection($container['settings']['db']);
  11. $capsule->setAsGlobal();
  12. $capsule->bootEloquent();
  13.  
  14. $app->get('/user/',function($request,$response){
  15. return $response->getBody()->write(
  16. User::all()->toJson());
  17. });
  18.  
  19. $app->run();
  20.  
  21.  
  22. <?php
  23. class User extends IlluminateDatabaseEloquentModel{
  24. protected $table='users';
  25.  
  26. }
  27. ?>
  28.  
  29.  
  30. <?php
  31. return[
  32. 'detemineRouteBeforeAppMiddleware'=>false,
  33. 'outputBuffering'=>false,
  34. 'displayErrorDetails'=>true,
  35. 'db'=>[
  36. "driver" => "mysql",
  37. "host" => "localhost",
  38. "database" => "restdb",
  39. "username" => "root",
  40. "password" => "",
  41. "charset" => "utf8",
  42. "collation" => "utf8_general_ci"
  43. ]
  44. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement