Download the PHP package cariboufute/locale-route without Composer

On this page you can find all versions of the php package cariboufute/locale-route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package locale-route

LocaleRoute, for localized testable routes in Laravel

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

LocaleRoute is a package to make testable localized routes with Laravel 5 to 10. 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.

Change log

Please see changelog for more information what has changed recently and what will be added soon.

Requirements

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

Laravel LocaleRoute
8.0 - 10.X 3.*
5.5 - 7.X 2.*
5.1 - 5.4 1.*

Install

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

For Laravel 5.4 and earlier

Since Laravel 5.5, Package Discovery installs service provider and alias automatically. But if you have Laravel 5.4 and earlier, add the service provider and the alias in .

Middleware

In your file, add the middleware in the web middleware group. This will read the locale from the 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.

Config file

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

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

Then you should have a installed.

Configuration

Check your file. Here is the default file.

Locales

Add all the locale codes needed for your website in .

For instance, if you want English, French, Spanish and German in your site...

Add locale automatically to URLs

This option is by default set to true. It prepends all URLs build by locale-route with a , according to Google Multi-regional and multilingual sites guidelines.

If for any reason, you don't want this prefix to be added automatically, just put this option to false, like this.

Usage

Adding routes

Adding localized routes is now really easy. Just go to your file (or in older versions of Laravel) and add declarations almost like you would declare Laravel methods.

For the first line, it is the equivalent of declaring this in pure Laravel, while having the app locale set to the right locale.

You can also give a string as locale URL if it is the same for all locales

Now, trailing methods are supported with LocaleRoute, as with the original Laravel Route facade.

So the syntax can be resumed to this.

Using translator files for URLs

You can also use the Laravel translator to put all your locale URLs in files. If there is no locale URL array, will automatically check for the translated files to find URLs. All you need to do is to remove the locale URL array in and declare them as in your translated route files, like this.

Note about localized and unlocalized routes using same base URL

If you declare localized and unlocalized routes using the same base URL, please declare your LocaleRoute method before the Route method. If you don't, the normal route will be discarded by the locale route attribution process.

For instance, if you declare a normal route with to redirect to the fallback locale (for instance, ) before the localized routes (for instance, and ), the localized routes with replace the first route before being added the locale. Declaring locale routes before the normal unlocalized route will cause no problems.

Middleware

If you want to use middleware for your LocaleRoute, add them in the url array (3rd parameter) in the key.

Grouping

You can use the methods inside normal methods.

Resource

To add a localized RESTful resource, just use with the same syntax as . This will give localized routes for all GET/HEAD routes and will keep the POST/PUT/PATCH/DELETE routes unlocalized.

If you want to translate the create and edit words in resources routes URL, add route-labels.php lang files in the resources/lang folder with translation for create and edit.

API resource

You can also use for the localized version of , which corresponds to without the and pages. The translated route labels will be the same as for .

Overriding options

You can override the and config options simply by declaring them in the url array.

Fetching URLs

gives three helper functions to help you get your URLs quickly. They are close to the Laravel helper function.

locale_route

This is the basic helper function. It calls the URL according to the locale, route name and parameters. When put to null, locale and route are set to the current values.

For the last three situations, there are clearer helper functions.

other_route

Calls another route URL in the same locale. The syntax is the same as Laravel .

other_locale

Calls the same route URL in another locale. For the syntax, we just replace the route name by the locale. Perfect for language selectors.

Contributing

Please see conduct for details.

Credits

License

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


All versions of locale-route with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
laravel/framework Version >=v8.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cariboufute/locale-route contains the following files

Loading the files please wait ....