daniel-griffiths / simple-route
A super simple routing class
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/daniel-griffiths/simple-route
Requires
- php: ~5.6|~7.0
This package is auto-updated.
Last update: 2025-09-29 02:06:22 UTC
README
A super simple router for mapping a url to a method on a class.
Installation
Via Composer
composer require daniel-griffiths/simple-route
Usage
<?php require __DIR__.'/vendor/autoload.php'; $router = new DanielGriffiths\Router($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); // long form for binding a route, supports get/post requests $router->add('GET', '/this-is-a-test', 'ExampleClassName@ExampleMethod'); // short hand for binding a route $router->get('/this-is-a-test', 'ExampleClassName@ExampleMethod'); $router->post('/this-is-a-test', 'ExampleClassName@ExampleMethod'); $router->dispatch();