pimolo / simple-router
A simple router. Not designed to be used in production.
v0.1
2016-07-13 20:57 UTC
Requires
- php: >=5.4
- symfony/http-foundation: ^3.1
Requires (Dev)
- phpspec/phpspec: ^2.5
This package is not auto-updated.
Last update: 2025-01-08 20:43:02 UTC
README
Installation
$ composer require pimolo/simple-router
Usage
<?php use Pimolo\SimpleRouter\Router; use Pimolo\SimpleRouter\DTO\Route; use Symfony\Component\HttpFoundation\Request; require_once 'vendor/autoload.php'; // Wrap the request with HttpFoundation $request = Request::createFromGlobals(); $kernel = new Router(); // Defines routes $home = (new Route('/home', ['GET'], function () { return 'Welcome to my app'; } )); $login = (new Route('/login', ['GET', 'POST'], function () { return 'Please login'; } )); // Handle the resource echo $kernel->route($request, [$home, $login]);
And if you want to test it :
$ php -S localhost:8000 main.php