<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/../vendor/autoloader.php'; use Sophwork\core\Sophwork; use Sophwork\app\app\SophworkApp; $autoloader->config = '/var/www/blueShell/src'; $app = new SophworkApp(['baseUrl' => '/blueShell/web']); $app->get('/', ['BlueShell\\Shell' => 'shell']); $app->run();
*/ $app->errors(function ($e, $errorCode) { echo '<h1>Custom Error !</h1>'; die; }); /** * Simply declare your routes and the patern to match * and link them to the controller in your sources * * You can match the following http requests * - get * - post * You can also attribute them a name so you can use UrlGenerator to create links */ // Separate controller file (recommended) $route = $app->get('/', ['MyApp\\Controller\\Home' => 'show'], 'home'); /** * You can use "controller hooks" to manage default behavior of your controllers * * "controller before hook" allows you to manage the Request before the controller is called * * NOTE : If a "before hook" or "controller before hook" returns a Responses object * the controller that match the route will not be run * and the response passe directly to the "after hook" */ $route->before(function ($app, $request) { echo 'before controller<br>'; // return new Responses('before controller that return a response object<br>'); }); /** * "controller after hook" allows you to manage the response after the controller have been called