<?php chdir(dirname(__DIR__)); require 'vendor/autoload.php'; // Init. $app = new Proton\Application(); $app['debug'] = true; error_reporting(E_ALL); ini_set('display_errors', 1); // Account routes. $app->post('/login', function ($request, $response) { $result = App\Api\AccountApi::login($request->get('email'), $request->get('password')); if ($result['success'] === true) { setcookie('token', serialize($result['data'])); } $response->setContent(json_encode($result)); return $response; }); $app->get('/user/{id}', function ($request, $response, $args) { $api = new App\Api\AccountApi(); $response->setContent(json_encode($api->getUser($args['id']))); return $response; }); $app->get('/employees', function ($request, $response) { $api = new App\Api\UserApi(); $response->setContent(json_encode($api->getAllEmployees())); return $response; }); // Shift routes. $app->get('/shifts', function ($request, $response) { $api = new App\Api\ShiftApi();
<?php $dotenv = new Dotenv\Dotenv(__DIR__ . '/../'); $dotenv->load(); /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | The first thing we will do is create a new application instance | which serves as the "glue" for all the components of the application, and is | the IoC container for the system binding all of the various parts. | */ $app = new Proton\Application(realpath(__DIR__ . '/../')); /* * Register ServiceProviders */ $app->registerConfiguredProviders(); /* * Include the app routes. */ require __DIR__ . '/../app/Http/routes.php'; /* * Include the Twig functions. */ require __DIR__ . '/twig.php'; /* |-------------------------------------------------------------------------- | Return The Application |--------------------------------------------------------------------------