PHP code example of sheepy85 / l5-localization

1. Go to this page and download the library: Download sheepy85/l5-localization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sheepy85 / l5-localization example snippets


// App\Http\Kernel.php
protected $stack = [
    ...
    'Sheepy85\L5Localization\Middleware\Localization',
];

// App\Providers\RouteServiceProvider.php
public function map( Router $router ) {
    

// config/app.php
'providers' => [
    ...
    'Sheepy85\L5Localization\L5LocalizationServiceProvider' ,
] ,

// routes.php
foreach ( Locale::codes( true ) as $code ) {
// or 
//foreach ( Locale::locales( true ) as $code => $locale ) {
   Route::group( [
	   'namespace' => '\App\Http\Controllers' ,
	   'prefix' => $code , 
	   ] , function() use( $code ) {

	  Locale::router()->get( '/' , 'home' , 'HomeController@index' , $code );
	  Locale::router()->get( 'routes.news' , 'news' , 'HomeController@news' , $code );
	  Locale::router()->post( 'login' , 'login' , 'AuthController@login' , $code );
   } );
}
cmd
> php artisan locale:select en es fr