n7olkachev/laravel-route-helpers

Rails-like route helpers for your Laravel application

v1.0.0 2018-08-06 21:36 UTC

This package is auto-updated.

Last update: 2024-12-23 21:45:29 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

https://websecret.by/en

Web agency based in Minsk, Belarus

License

The MIT License (MIT)