rabpack / routing
Routing
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
This package is auto-updated.
Last update: 2025-07-18 18:19:14 UTC
README
#Install Package :
"composer require rabpack/routing"
For Run Routing in index.php file new object of Application Class:
$app = new Application();
then for use of this class should create a one file in project.
For example, create a file named Web in your project:
Web.php Contents :
use Rabpack\Routing\Web\Route;
Route::get('/','HomeController@index');
Route::get('/posts','HomeController@post');
This file is used to define the route.
then should this file add to index.php :
index.php :
require autoload.php :
require_once dirname(__DIR__)."/vendor/autoload.php";
create new object Application class :
$app = new Rabpack\Routing\Application\Application();
call method globalRoutes for create HttpVerbs :
$app->globalRoutes();
require routes file : <br>
require_once dirname(__DIR__)."/routes/web.php";
require_once dirname(__DIR__)."/routes/api.php";
call method loadConfig :
$app->loadConfig("root path","controllers dir path","Controllers Namespace");
Example Create Routes :
use Rabpack\Routing\Web\Route;
Route::get('/','HomeController@index'); // route : http://example.com => controller : HomeController => method : index
Route::get('/posts','PostController@index'); // route : http://example.com/posts => controller : PostController => method : index
Route::namespace('Admin')->prefix('admin')->group(function () {
Route::get('/','DashboardController@index'); // route : http://example.com/admin/ => controller : Admin\DashboardController => method : index
Route::prefix('post')->group(function () {
Route::get('/','PostController@index'); // route : http://example.com/admin/post/ => controller : Admin\PostController => method : index
Route::get('/show','PosrController@show'); // route : http://example.com/admin/post/show => controller : Admin\PostController => method : show
Route::put('/edit/{id}','PostController@edit'); // route : http://example.com/admin/post/edit/115 => controller : Admin\PostController => method : edit
});
});