library simple-router
A simple router. Not designed to be used in production.
pimolo/simple-router
A simple router. Not designed to be used in production.
- Wednesday, July 13, 2016
- by pimolo
- Repository
- 1 Watchers
- 0 Stars
- 4 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
SimpleRouter
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 :, (*1)
$ php -S localhost:8000 main.php
dev-master
9999999-dev
A simple router. Not designed to be used in production.
Sources
Download
MIT
The Requires
The Development Requires
by
Rémi Andrieux
v0.1
0.1.0.0
A simple router. Not designed to be used in production.
Sources
Download
MIT
The Requires
The Development Requires
by
Rémi Andrieux