meraki / route
v0.8.0
2021-08-13 11:52 UTC
Requires
- php: ^8
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- willdurand/negotiation: ^3.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.6
- meraki/test-suite: ^0.3
- narrowspark/http-emitter: ^2.0
This package is auto-updated.
Last update: 2024-12-25 02:14:58 UTC
README
Frameware-agnostic, Middleware-compatible routing framework for PHP 7+.
Installation
Composer
To install using Composer, enter the following at the command line:
composer require meraki/route
Usage
Getting Started
<?php require_once 'vendor/autoload.php'; use Meraki\Route\Collection; use Meraki\Route\Mapper; use Meraki\Route\Matcher; use Meraki\Route\MatchResult; // any psr7 and psr11 compliant library will work use Laminas\Diactoros\ServerRequestFactory; $map = new Mapper(new Collection()); $map->get('/', new ShowHomepage()); $map->get('/contact', new ShowContactForm()); $map->post('/contact', new SendContactForm()); $map->get('/users/:id', new DisplayEditUserForm()) ->name('display.user.profile') ->constrain(':id', Constraint::digit()); $map->get('/users/:id'); $matcher = new Matcher($map->getRules()); $result = $match->match(ServerRequestFactory::fromGlobals()); if ($result->isSuccessful()) { // handle a successful match } else { // handle a failed match 404,405,406,etc. }
Full Documentation
See the Wiki.
Testing
To run the tests, run the following script:
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email nbish11@hotmail.com instead of using the issue tracker.
Credits
Without help from the following people, software and services, this project would not have been possible. So a big thank you to all.
Authors
Contributors
Software
Services
License
The MIT License (MIT). Please see the LICENSE file for more information.