PHP code example of alkhatibdev / language-switcher

1. Go to this page and download the library: Download alkhatibdev/language-switcher 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/ */

    

alkhatibdev / language-switcher example snippets


// config/language-switcher.php

'assign_globally' => false,

// routes/web.php

// Assign to individual route
Route::get('/{locale}/home', [HomeController, 'home'])->middleware(['switchlocale']);


// Assign to route group
Route::->middleware(['switchlocale'])->group(function () {
    //
});

// app/Http/kernel.php

protected $middlewareGroups = [
    'web' => [
        // ...
        'switchlocale',
    ],

    'api' => [
        // ...
        'switchlocale',
    ],
];

// config/language-switcher.php

'enable_session' => false,
bash
php artisan vendor:publish --tag=language-switcher-config