1. Go to this page and download the library: Download codehouse/highway library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$builder = new \DI\ContainerBuilder();
$builder->useAnnotations(true);
$router->setDiContainer($builder->build());
class SecurityHandler
{
public static function admin()
{
$auth = new \Services\Authentication();
if ($auth->getLoggedInUserRole() != UserRoles::ADMIN) {
throw new InvalidRoleException('Role needed: ' . UserRoles::ADMIN . ', Role found: ' . $auth->getLoggedInUserRole());
}
}
}
$router = new CodeHouse\Highway\Router(__DIR__ . '/src/Controller', 'Controller', new SecurityHandler());
echo $router->serve($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
use \CodeHouse\Highway\Annotations as Highway;
/**
* @Highway\Controller
*/
class SomeController { .. }
use \CodeHouse\Highway\Annotations as Highway;
...
/**
* @Highway\RequestMapping(value="/users", method="get")
*/
public function listUsers() { ... }
...
use \CodeHouse\Highway\Annotations as Highway;
...
/**
* @Highway\Security(role="admin")
*/
public function adminOnlyMethod() { ... }
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.