n7olkachev / laravel-route-helpers
Rails-like route helpers for your Laravel application
v1.0.0
2018-08-06 21:36 UTC
Requires
- laravel/framework: ^5.5
Requires (Dev)
- orchestra/testbench: ~3.0
This package is auto-updated.
Last update: 2024-10-23 21:32:42 UTC
README
Rails like route helpers for your Laravel application.
Why?
Fully autocompletable routes. Less typing, less errors.
Examples
// routes.php \Route::group(['prefix' => '/admin', 'as' => 'admin.'], function () { \Route::get('/')->name('home'); \Route::group(['prefix' => '/users', 'as' => 'users.'], function () { \Route::get('/{user}')->name('show'); }); });
This package will generate special helpers for you, so you can generate urls like:
admin_home_url(); admin_users_show_url(['user' => $user->id]);
It's totally IDE friendly, so after typing admin_
you'll see both helpers as suggestions!
Installation
You can install the package via composer:
composer require n7olkachev/laravel-route-helpers
To create helpers run:
php artisan route:helpers
Then you just need to add generated file to composer autoload section, like so:
// composer.json ... "autoload": { "files": [ "storage/route-helpers/cache.php" ], } ...
The path of generated file can be changed via config.
Testing
$ composer test
Credits
Sponsored by
Web agency based in Minsk, Belarus
License
The MIT License (MIT)