This package is a simple PSR-4 router for PHP.
Via Composer
$ composer require alkimisti/simplerouter:dev-main
$router = new Router();
$router->resolve();
The first URL segment will be used as the name of the controller; /home
will instantiate App\Controllers\HomeController.php
.
The second URL segment will be used as the name of the action/method; /home/index
will invoke index()
method in App\Controllers\HomeController
.
Other segments will be forwarded as method arguments; /products/show/5
will invoke show()
method in App\Controllers\ProductsController
, passing the number 5
as its first argument.
Tutorial: https://codemolecules.com/php/a-simple-psr-4-router-for-php/
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
- [Tahir Hoxha][link-author]
- [All Contributors][link-contributors]
The MIT License (MIT). Please see License File for more information.