laravel-lang/config
Language configuration companion for the Laravel Lang ecosystem. Provides shared config resources used across Laravel Lang packages, with Composer installation and MIT licensing. Includes contribution guidelines and ways to support the project.
config() helper, service providers, and caching mechanisms. Aligns perfectly with Laravel’s architecture (e.g., config/app.php bindings, facades).es_MX → es → en), reducing boilerplate for multilingual apps.config('app.name.es')) and scale to full localization without refactoring.LaravelLangConfig), improving testability and IDE support.composer require laravel-lang/config).config/app.php.php artisan vendor:publish --provider="LaravelLangConfigServiceProvider").VENDOR_PATH env var) for autocompletion.| Risk Area | Mitigation Strategy |
|---|---|
| Cache Invalidation | Automate config:clear via Git hooks or CI/CD (e.g., post-deploy script). |
| Fallback Logic | Test edge cases (missing locales, circular fallbacks) in staging. |
| Performance | Benchmark config loading in high-traffic scenarios; cache warm-up may be needed. |
| File-Based Limits | For real-time updates, pair with Redis or a config service (e.g., LaunchDarkly). |
| Laravel Version Lock | Package supports Laravel 11–13; pin version in composer.json to avoid surprises. |
| Namespace Collisions | Use unique config keys (e.g., lang_config.app.name instead of app.name). |
config('app.locale')) or user-specific (e.g., config('user_prefs.theme'))?en)?es_MX → es → en vs. es_MX → es (no default).venturecraft/reverb.config:clear, CI/CD, or live reload)?config('services.stripe.endpoint.eu') in CI.config() with manual merging logic?laravel-translation (better for models) or Symfony’s ParameterBag?LaravelLangConfigServiceProvider).LaravelLangConfig).config() helper).vendor:publish, config:clear).VENDOR_PATH.Config facade or config() helper.config('services.stripe.endpoint') → config('services.stripe.endpoint.{locale}'.es_MX → es → en).php artisan vendor:publish --provider="LaravelLangConfigServiceProvider".config('locale_key.value').// Before
Route::get('/contact', function () {
return 'Email: contact@example.com';
});
// After
Route::get('/contact', function () {
return 'Email: ' . config('app.contact_email');
});
config:clear).config() calls with invalid keys).| Component | Compatibility Notes |
|---|---|
| Laravel | Tested on Laravel 11–13. Avoid Laravel 10 (unsupported). |
| PHP | Requires PHP 8.0+. No breaking changes for PHP 8.1+. |
| Composer | Standard composer require installation. No custom scripts needed. |
| Caching | Uses Laravel’s built-in config caching. No additional cache layers required. |
| Middleware | Supports dynamic locale switching via middleware (e.g., set app.locale per request). |
| Testing | Mockable via Laravel’s Config facade or config() helper. |
| IDE | Auto-generates IDE helpers (configurable via VENDOR_PATH). |
config() system.composer require laravel-lang/config.config/app.php:
'providers' => [
LaravelLangConfigServiceProvider::class,
],
php artisan vendor:publish --provider="LaravelLangConfigServiceProvider".config/locales/{locale}.php (e.g., es.php, fr.php).// config/locales/es.php
return [
'app' => [
'name' => 'Mi App',
'contact_email' => 'contacto@miapp.es',
],
'services' => [
'stripe' => [
'endpoint' => 'https://api.stripe.eu/v1',
],
],
];
config/lang_config.php:
'fallbacks' => [
'es_MX' => ['es', 'en'],
'fr_CA' => ['fr', 'en'],
],
config('locale_key.value'):
$appName = config('app.name'); // Falls back to default locale
$euEndpoint = config('services.stripe.endpoint.eu'); // Explicit locale
public function handle(Request $request, Closure $next) {
config(['app.locale' => $request->header('Accept-Language')]);
return $next($request);
}
How can I help you explore Laravel packages today?