/laravel-localization-route-cache

Translated Route Caching Solution for Laravel Localization

Primary LanguagePHPMIT LicenseMIT

Translated Route Caching Solution for Laravel Localization

Software License

A cobbled together fix to allow caching routes per locale for mcamara's laravel localization.

See the github issue related to this fix in the original package.

This has been tested with laravel 5.1 through 5.4.

Version Compatibility

Laravel Package
5.1.x 0.8.x
5.2.x and up 0.9.x

Install

Via Composer

$ composer require czim/laravel-localization-route-cache

In your config/app.php config, add the service provider after mcamara's:

    Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class,
    Czim\LaravelLocalizationRouteCache\LaravelLocalizationServiceProvider::class,

In your App's RouteServiceProvider, use the LoadsTranslatedCachedRoutes trait:

class RouteServiceProvider extends ServiceProvider
{
    use \Czim\LaravelLocalizationRouteCache\Traits\LoadsTranslatedCachedRoutes;

Usage

To cache your routes, use

    php artisan route:trans:cache

instead of the normal route:cache command.

To list the routes for a given locale, use

    php artisan route:trans:list {locale}
    
    # for instance:
    php artisan route:trans:list en

To clear cached routes for all locales, use

    php artisan route:trans:clear

Note that using route:clear will also effectively unset the cache (at the minor cost of leaving some clutter in your bootstrap/cache directory).

Credits

License

The MIT License (MIT). Please see License File for more information.