elvislakota / router
Fast routing built with FastRoute.
dev-master / 1.0.x-dev
2019-01-13 01:42 UTC
Requires
- php: >=7.1.25
- narrowspark/http-emitter: ^0.7.0
- nikic/fast-route: ^1.3
- zendframework/zend-diactoros: ^2.1
Requires (Dev)
This package is not auto-updated.
Last update: 2025-03-07 04:42:39 UTC
README
This package is compliant with PSR-7. If you notice compliance oversights, please send a patch via pull request.
Install
Via Composer
$ composer require elvislakota/router:dev-master
Requirements
The following versions of PHP are supported by this version.
- PHP 7.1
- PHP 7.2
Usage
Here's a basic usage example:
.htaccess
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();
Testing
$ vendor/bin/phpunit
Contributing
Contributions are welcome and will be fully credited.
We accept contributions via Pull Requests on Github.
Credits
- Elvis Lakota
- Nikita Popov (FastRoute)
- Narrowspark (http-emitter)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.