https://github.com/mojtabaahn/laravel-controller-aware-routes
Adds Controller-Aware Routes To Laravel
https://github.com/mojtabaahn/laravel-controller-aware-routes
laravel
Last synced: 6 months ago
JSON representation
Adds Controller-Aware Routes To Laravel
- Host: GitHub
- URL: https://github.com/mojtabaahn/laravel-controller-aware-routes
- Owner: mojtabaahn
- License: mit
- Created: 2020-08-18T10:07:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-08T18:51:17.000Z (almost 6 years ago)
- Last Synced: 2025-11-27T15:28:25.102Z (7 months ago)
- Topics: laravel
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Controller Aware Routes
[](https://packagist.org/packages/mojtabaahn/laravel-controller-routes)
[](https://packagist.org/packages/mojtabaahn/laravel-controller-routes)
[](https://packagist.org/packages/mojtabaahn/laravel-controller-routes)
[](https://packagist.org/packages/mojtabaahn/laravel-controller-routes)
## Requirement
This package requires **PHP 7.4** or higher.
## Installation
You can install the package via composer:
```bash
composer require mojtabaahn/laravel-controller-routes
```
## Usage
``` php
methods(function (ControllerAwareRouter $router) {
$router->get('user/{user}', 'profile')->name('user.profile');
$router->get('user/{user}/post/{post}','post')->name('user.post');
});
// Or
Routes::make()
->controller('UserController')
->methods(function (ControllerAwareRouter $router) {
$router->get('user/{user}', 'profile')->name('user.profile');
$router->get('user/{user}/post/{post}','post')->name('user.post');
});
// Same as
Route::get('user/{user}', 'UserController@profile')->name('user.profile');
Route::get('user/{user}/post/{post}','UserController@posts')->name('user.posts');
// Using RouteRegistrar methods
Routes::make()
->prefix('user/{user}')
->name('user.')
->middleware('web')
->controller('UserController')
->methods(function (ControllerAwareRouter $router) {
$router->get('/', 'profile')->name('profile');
$router->get('posts','posts')->name('posts');
});
// same as
Route::prefix('user/{user}')
->name('user.')
->middleware('web')
->group(function(){
Route::get('/', 'UserController@profile')->name('profile');
Route::get('posts','UserController@posts')->name('posts');
});
```
## Testing
``` bash
composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.