This package is compliant with PSR-7. If you notice compliance oversights, please send a patch via pull request.
Via Composer
$ composer require elvislakota/router:dev-master
The following versions of PHP are supported by this version.
- PHP 7.1
- PHP 7.2
Here's a basic usage example:
Create a .htaccess file in your htdocs folder
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) public/ [L]
</ifModule>
Then create a new Folder 'public' in your htdocs folder and add index.php with content
<?php
require '../vendor/autoload.php';
//Your middleware class
$middlewareTest = new \elvislakota\Router\example\MiddlewareTest();
//Custom error messages for the error 404,405 and middleware
$exceptionTest = new \elvislakota\Router\example\ExceptionTest();
//Router
$router = new \elvislakota\Router\Router($exceptionTest);
//Add a route
$router->addRoute(\elvislakota\Router\Router\Route::getRoute('GET','/',
'elvislakota\Router\example\ControllerTest::helloWorld', $middlewareTest));
//Dispatch and emit data
$serverResponse = $router->dispatch();
$router->emit();
$ vendor/bin/phpunit
Contributions are welcome and will be fully credited.
We accept contributions via Pull Requests on Github.
- Elvis Lakota
- Nikita Popov (FastRoute)
- Narrowspark (http-emitter)
- All Contributors
The MIT License (MIT). Please see License File for more information.