meraki/route

v0.8.0 2021-08-13 11:52 UTC

This package is auto-updated.

Last update: 2024-04-25 00:53:11 UTC


README

Scrutinizer Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Packagist Latest Stable Version MIT License

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.