benatespina/i18n-routing-bundle
JMSI18nRoutingBundle, a well-established solution for internationalized routing in Symfony/Laravel (via Symfony components). If the product already uses JMSI18nRoutingBundle or plans to adopt it, this package provides a low-risk, incremental enhancement for missing features (e.g., route parameter handling, locale fallback logic, or edge-case routing).JMSI18nRoutingBundle. A TPM should validate whether these gaps exist in the product’s current stack (e.g., manual locale handling, brittle route generation) before adoption.Router in Laravel’s RouteServiceProvider).RouteServiceProvider::boot()), while Symfony’s is container-configured. The TPM must decide between:
Router configuration to Laravel (high effort, high risk).JMSI18nRoutingBundle or Laravel’s built-in tools (e.g., localization middleware in Laravel 8+).spatie/laravel-translatable-routes, mcamara/laravel-localization).JMSI18nRoutingBundle? If not, what’s the cost-benefit of adopting it alongside this bundle?Router is tightly coupled to Symfony’s DI; Laravel’s Container may need custom bindings.Router and EventDispatcher, requiring minimal configuration.RouteServiceProvider vs. Symfony’s routing.yml/annotation routing.bind() vs. Symfony’s XML/YAML configuration.symfony/http-kernel), the bundle can be integrated as-is with minimal glue code.JMSI18nRoutingBundle (if not present) and this bundle via Composer.config/packages/routing.yml (or equivalent).public function handle($request, Closure $next) {
$symfonyRequest = new SymfonyRequest($request);
$router = $this->app->make('router'); // Symfony Router
$context = $router->getContext();
$context->setParameter('locale', $request->segment(1)); // Extract locale from URL
$request->setPathInfo($router->generate($request->getPathInfo()));
return $next($request);
}
RouteServiceProvider::map() to integrate Symfony’s route loader.public function map()
{
$loader = new SymfonyRouteLoader($this->app);
$this->router->setRouteCollection($loader->load());
}
/en/users, /es/users).route:cache may need adjustments.Bundle system; Laravel’s ServiceProvider must replicate this.UrlGenerator differs from Laravel’s Url::to(). A facade or helper class may be needed.JMSI18nRoutingBundle./:locale/product).route('product', ['locale' => 'es'])).How can I help you explore Laravel packages today?