alineisi / router
this package is used to implement routing system with a lot of cool features !!!
1.0
2022-04-28 10:12 UTC
README
Routing system for PHP
Requries PHP >= 7.0
Installation
composer require alineisi/router
To get started
require_once __DIR__ . '/vendor/autoload.php';
use Alineisi\Route;
be sure adding
Route::dispatch();
end of index.php
Usage
ex.1
Route::get('/', function () {
return 'Hello World';
});
ex.2
Route::get('/', [HomeController::class, 'index']);
ex.3
Route::post('/submit', function () {
return $_POST['name'];
});
Features
you can set not found page by using
Route::notFoundPath($path);
set named routes by using name method after routing, for example:
Route::get('/', function () {
return 'Hello World';
})->name('index');
and to use it:
\Alineisi\routeName('index');
you can also returning views by using
Route::view('/', 'index');
or
Route::view('/', 'index.php');