Download the PHP package larasofthu/localized-routes-plus without Composer
On this page you can find all versions of the php package larasofthu/localized-routes-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download larasofthu/localized-routes-plus
More information about larasofthu/localized-routes-plus
Files in larasofthu/localized-routes-plus
Package localized-routes-plus
Short Description 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.
License MIT
Homepage https://github.com/LarasoftHU/localized-routes-plus
Informations about the package localized-routes-plus
Laravel Localized Routes Plus
A powerful Laravel package for creating localized routes with advanced features including subdomain support, country-specific routing, and automatic locale management.
Features
🌍 Multiple Localization Strategies
- URL prefix-based localization (
/en/page
,/hu/page
) - Subdomain-based localization (
en.example.com
,hu.example.com
) - Country-specific routing (
/en-us/page
,/en-ca/page
)
🚀 Framework Integration
- Seamless Laravel Route integration
- Automatic middleware registration
- Resource route support
- Custom route model binding
⚙️ Flexible Configuration
- Whitelist/blacklist locales
- Configurable separators
- Multiple domains per locale
- Default locale customization
🔧 Developer-Friendly
- Intuitive API design
- Helper methods for URL generation
- Comprehensive testing
- Full IDE support
Installation
Install the package via Composer:
Publish the configuration file:
Quick Start
Basic Usage
Create localized routes by chaining the localized()
method:
Resource Routes
Configuration
The configuration file (config/localized-routes-plus.php
) contains all available options:
URL Prefix Localization
Basic Configuration
Route Examples
Including Default Locale in URLs
Subdomain Localization
Configuration
Multiple Domains per Locale
Route Examples
Country-Specific Routing
Configuration
Multiple Countries per Locale
Path Separators
Route Examples
Selective Localization
Whitelist Specific Locales
Blacklist Specific Locales
Advanced Usage
Route Model Binding
Route Parameters
Middleware Integration
The package automatically registers middleware to set the application locale:
Helper Methods
Route Switching
URL Generation
Route Information
Blade Helpers
Language Switcher
Current Locale Detection
Testing
The package includes comprehensive tests covering all functionality:
API Reference
LocalizedRoute Methods
Method | Description | Example |
---|---|---|
localized($locales = []) |
Create localized versions | ->localized(['en', 'hu']) |
localizedExcept($locales = []) |
Exclude specific locales | ->localizedExcept('de') |
locale($locale, $country = null) |
Get route for locale | $route->locale('hu') |
getUrl($locale = null, $country = null) |
Generate URL for locale | $route->getUrl('de') |
getLocale() |
Get route locale | $route->getLocale() |
getCountry() |
Get route country | $route->getCountry() |
getSafeName() |
Get name without locale prefix | $route->getSafeName() |
is($name) |
Check route name (locale-agnostic) | $route->is('products.index') |
Configuration Options
Option | Type | Default | Description |
---|---|---|---|
locales |
array |
['en'] |
Available locales |
default_locale |
string |
'en' |
Default application locale |
use_route_prefix_in_default_locale |
bool |
false |
Include prefix for default locale |
use_subdomains_instead_of_prefixes |
bool |
false |
Use subdomains instead of prefixes |
domains |
array |
[] |
Domain mapping for locales |
use_countries |
bool |
false |
Enable country-specific routing |
country_path_separator |
string |
'dash' |
Separator between locale and country |
countries |
array |
[] |
Country mapping for locales |
Middleware
Class | Description | Auto-Applied |
---|---|---|
SetLocaleFromRoute |
Sets App::setLocale() from route |
✅ Yes |
SetCountryFromRoute |
Sets App::setCountry() from route |
✅ When countries enabled |
Examples
E-commerce Site
Multi-Country Site
Subdomain Setup
Troubleshooting
Common Issues
Route names must be set before localized()
Missing domain configuration for subdomains
Country parameter required when countries enabled
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Security
If you discover any security vulnerabilities, please email [email protected] instead of using the issue tracker.
Credits
- Kapási Fülöp
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of localized-routes-plus with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^9.0||^10.0||^11.0||^12.0