PHP code example of hoyvoy / laravel-subdomain-localization
1. Go to this page and download the library: Download hoyvoy/laravel-subdomain-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/ */
hoyvoy / laravel-subdomain-localization example snippets
...
use Hoyvoy\Localization\Facades\Localize;
...
public function boot(Router $router)
{
// This will guess a locale from the current HTTP request
// and set the application locale
Localize::detectLocale();
parent::boot($router);
}
...
// Without the localize middleware, this route can be reached with or without language subdomain
Route::get('logout', 'AuthController@logout');
// With the localize middleware, this route cannot be reached without language subdomain
Route::group([ 'middleware' => [ 'localize' ]], function() {
Route::get('welcome', 'WelcomeController@index');
});