Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Localized Routes Plus

Localized Routes Plus Laravel Package

larasofthu/localized-routes-plus

View on GitHub
Deep Wiki
Context7

Advanced Laravel package for creating localized routes with subdomain support, country-specific routing, and automatic locale management. Supports URL prefixes, subdomains, and multi-country localization strategies.

Frequently asked questions about Localized Routes Plus
How do I install and configure **Localized Routes Plus** for Laravel 10+?
Run `composer require larasofthu/localized-routes-plus` and publish the config with `php artisan vendor:publish --tag=localized-routes-plus-config`. Edit the config to define supported locales, default strategies (prefix/subdomain), and route separators like `/en/` or `en.example.com`.
Does this package support subdomain-based localization (e.g., `hu.example.com`)?
Yes, it fully supports subdomain routing. Configure it in the `localized_routes_plus.php` config under `strategies.subdomain`. Ensure your DNS and server (Nginx/Apache) support wildcard subdomains (e.g., `*.example.com`).
Can I mix prefix and subdomain strategies in the same Laravel app?
No, you must choose one primary strategy per route group. However, you can define multiple route groups with different strategies (e.g., prefix for `/blog` and subdomain for `/shop`). Use route macros or middleware to handle edge cases.
How does locale detection work? Does it override Laravel’s default locale?
Locale detection prioritizes subdomain > URL prefix > browser `Accept-Language` header. It integrates with Laravel’s middleware pipeline, so you can customize the logic via hooks in the config. Existing locale resolution (e.g., from sessions) remains unaffected unless explicitly overridden.
Will this package work with Laravel’s route caching (`php artisan route:cache`)?
Yes, the package is fully compatible with Laravel’s route caching. Localized routes are generated during caching, so there’s no runtime overhead. Test caching in staging to ensure no conflicts with dynamic route generation.
How do I handle unsupported locales (e.g., a user visits `/fr/page` but French isn’t configured)?
Configure a fallback locale in the `localized_routes_plus.php` config under `fallback_locale`. By default, it redirects to the default locale (e.g., `/en/page`). You can also throw a 404 or use middleware to handle custom logic.
Does this package support country-specific routes (e.g., `/en-us`, `/en-ca`)?
Yes, use the `country` strategy in your route definitions. Configure supported countries in the `localized_routes_plus.php` config under `countries`. Combine with locales (e.g., `en-us`, `hu-hu`) for granular routing.
Can I use this with API routes (e.g., `/api/en/users`) without breaking CORS?
Prefix-based routes (e.g., `/api/en/users`) work well for APIs. Ensure your CORS middleware allows the dynamic locale prefixes. Subdomain-based APIs (e.g., `api.en.example.com`) may require additional CORS configuration for cross-subdomain requests.
How do I generate localized URLs in Blade or PHP (e.g., for links or redirects)?
Use the `localized_route()` helper method, which automatically resolves the current locale. Example: `localized_route('about')` generates `/about`, `/hu/about`, or `hu.example.com/about` based on the active strategy. For dynamic locales, pass a second argument: `localized_route('about', 'de')`.
Are there performance concerns with subdomain routing in high-traffic Laravel apps?
Subdomain routing adds DNS lookup latency, which can impact performance. Mitigate this by using a CDN with edge caching (e.g., Cloudflare) or pre-warming DNS records. Prefix-based routing is lighter and recommended for API-heavy or latency-sensitive applications.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony