alkimisti/simplerouter

A simple PSR-4 router

dev-main 2020-12-10 23:34 UTC

This package is auto-updated.

Last update: 2024-05-11 05:13:48 UTC


README

This package is a simple PSR-4 router for PHP.

Install

Via Composer

$ composer require alkimisti/simplerouter:dev-main

Usage

$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/

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Credits

  • [Tahir Hoxha][link-author]
  • [All Contributors][link-contributors]

License

The MIT License (MIT). Please see License File for more information.