-
composer.json
Open in GitHub"require": { "php": "^7.3|^8.0", // "codezero/laravel-localized-routes": "^2.5", // },
-
config/localized-routes.php
Open in GitHubreturn [ 'supported-locales' => [ 'en', 'de', 'es', // ], 'locales-name-native' => [ 'en' => 'English', 'de' => 'Deutsch', 'es' => 'Español', ], ];
-
app/Http/Kernel.php
Open in GitHubuse Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { protected $middlewareGroups = [ 'web' => [ // \App\Http\Middleware\VerifyCsrfToken::class, \CodeZero\LocalizedRoutes\Middleware\SetLocale::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, // ], ]; }
-
main/routes/web.php
Open in GitHubuse App\Http\Controllers\LaravelVersionsController; use CodeZero\LocalizedRoutes\Controller\FallbackController; use CodeZero\LocalizedRoutes\Middleware\SetLocale; use Illuminate\Support\Facades\Route; Route::localized(function () { Route::get('/', [LaravelVersionsController::class, 'index'])->name('versions.index'); Route::get('{version}', [LaravelVersionsController::class, 'show'])->name('versions.show'); }); Route::fallback(FallbackController::class)->middleware(SetLocale::class);