edom / simple-router-php
Simple Router in PHP to use in small projects
Installs: 67
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/edom/simple-router-php
This package is auto-updated.
Last update: 2025-09-24 17:04:38 UTC
README
.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
Start with package
require_once "../vendor/autoload.php"; use EDOM\SimpleRouterPHP\Router; $router = new Router("EDOM\\");
Router receive as parameter the namespace where you manage your controllers
GET
$router->get('/', function () { echo "get"; }); $router->get('/users/[i:id]', 'UsersController@show');
POST
$router->post('/', function () { echo "post"; }); $router->post('/users/[i:id]', 'UsersController@store');
PUT
$router->put('/', function () { echo "put"; }); $router->put('/users/[i:id]', 'UsersController@update');
DELETE
$router->delete('/', function () { echo "delete"; }); $router->delete('/users/[i:id]', 'UsersController@delete');
The structure to pass a controller is Class@method
Finally call this method
$router->match();