PHPackages                             cariboufute/locale-route - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. cariboufute/locale-route

ActiveLibrary[Localization &amp; i18n](/categories/localization)

cariboufute/locale-route
========================

A testable route package with localization for Laravel 5 to 12

3.0.6(3mo ago)206.7k—0%3[1 PRs](https://github.com/cariboufute/locale-route/pulls)MITPHPPHP &gt;=7.3CI failing

Since Nov 6Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/cariboufute/locale-route)[ Packagist](https://packagist.org/packages/cariboufute/locale-route)[ Docs](https://github.com/cariboufute/locale-route)[ RSS](/packages/cariboufute-locale-route/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (31)Used By (0)

LocaleRoute, for localized testable routes in Laravel
=====================================================

[](#localeroute-for-localized-testable-routes-in-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b4c8fb68905e04e714c1c8ecec2621b7824c9a001c43c0d709b6b502fe34ef8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63617269626f75667574652f6c6f63616c652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cariboufute/locale-route)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](license.md)[![Build Status](https://camo.githubusercontent.com/4419f29ad199c59b03d78b6e6105629cb672c0cb00c2ad77a34717947e1d79b9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63617269626f75667574652f6c6f63616c652d726f7574652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/cariboufute/locale-route)[![Coverage Status](https://camo.githubusercontent.com/d634d50d4df5ac1ef275df8484d2ade719072e39c93f9b4ee6ca27bbe34f35a4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f63617269626f75667574652f6c6f63616c652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cariboufute/locale-route/code-structure)[![Quality Score](https://camo.githubusercontent.com/2eee73a752abe9ab56946ac56ace7a9c677c9201f07345750086487893435844/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f63617269626f75667574652f6c6f63616c652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cariboufute/locale-route)[![Total Downloads](https://camo.githubusercontent.com/e5da037332ff24d5e1388f1edc840914a3d79523e06d7b774f1aae9190c1815f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63617269626f75667574652f6c6f63616c652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cariboufute/locale-route)

**LocaleRoute** is a package to make testable localized routes with Laravel 5 to 12. It comes from the need to have localized routes that are fully testable.

LocaleRoute has a syntax close to the original Laravel routing methods, so the installation and learning curve should be quite easy.

For an example of LocaleRoute implementation, please check my [locale-route-example repo](https://github.com/cariboufute/locale-route-example).

Change log
----------

[](#change-log)

Please see [changelog](changelog.md) for more information what has changed recently and what will be added soon.

Requirements
------------

[](#requirements)

Please choose your version of LocaleRoute according to your version of Laravel.

LaravelLocaleRoute8.0 - 12.X3.\*5.5 - 7.X2.\*5.1 - 5.41.\*Install
-------

[](#install)

First install the package through Composer by typing this line in the terminal at the root of your Laravel application.

```
composer require cariboufute/locale-route
```

### For Laravel 5.4 and earlier

[](#for-laravel-54-and-earlier)

Since Laravel 5.5, Package Discovery installs service provider and `LocaleRoute` alias automatically. But if you have Laravel 5.4 and earlier, add the service provider and the `LocaleRoute` alias in `config/app.php`.

```
// config/app.php

'providers' => [
    //...
    CaribouFute\LocaleRoute\LocaleRouteServiceProvider::class,
    //...
],

'aliases' => [
    //...
    'LocaleRoute' => CaribouFute\LocaleRoute\Facades\LocaleRoute::class,
],
```

### Middleware

[](#middleware)

In your `app/Http/Kernel.app` file, add the `SetLocale` middleware in the web middleware group. This will read the locale from the `locale` session variable, saved by each localized route and will keep the locale for redirections, even after using unlocalized routes to access models CRUD routes, for instance.

```
// app/Http/Kernel.app

protected $middlewareGroups = [
    'web' => [
        //...
        \CaribouFute\LocaleRoute\Middleware\SetLocale::class,
    ],

    //...
];
```

### Config file

[](#config-file)

Finally install the config file of the package by typing this line in the terminal at the root of your Laravel application.

```
php artisan vendor:publish
```

To bypass the package selection prompt, type this line instead.

```
php artisan vendor:publish --provider "CaribouFute\LocaleRoute\LocaleRouteServiceProvider"
```

Then you should have a `config/localeroute.php` installed.

Configuration
-------------

[](#configuration)

Check your `config/localeroute.php` file. Here is the default file.

```
// config/localeroute.php
