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.
## Product Decisions This Supports
- **Globalization & Localization Strategy**: Enables dynamic, language/region-specific configurations (e.g., API endpoints, feature flags, UI strings) without hardcoding. Critical for scaling multilingual SaaS platforms, regional compliance (e.g., GDPR, tax laws), or localized user experiences (e.g., date formats, payment gateways).
- *Example*: Serve `config('services.stripe.endpoint.eu')` for EU users automatically.
- **Build vs. Buy Decision**: Eliminates the need to build a custom configuration localization system, saving **3–6 months of development time** while leveraging Laravel’s ecosystem. Ideal for teams prioritizing **velocity** and **maintainability**.
- **Key Use Cases**:
- **Multilingual SaaS**: Localize configs for regions (e.g., `config('legal.terms.es')` for Spain).
- **Progressive Web Apps (PWAs)**: Dynamically load language-specific feature toggles or UI themes (e.g., `config('ui.theme.dark_mode')`).
- **Legacy Modernization**: Gradually introduce localization to monolithic apps by migrating configs incrementally.
- **A/B Testing**: Route users to language-specific configurations (e.g., `config('experiment.cta_button.fr')`) without code changes.
- **Compliance**: Enforce region-specific configs (e.g., `config('privacy.policy.gdpr')`).
- **Cost Optimization**: Reduces translation tooling costs by centralizing locale-aware configs in PHP files (e.g., `config/locales/en.php`), avoiding duplication in databases or external services.
- **Developer Experience**: Integrates seamlessly with Laravel’s existing `config()` helper, requiring minimal learning curve.
---
## When to Consider This Package
### **Adopt If**:
- Your Laravel app requires **language/region-specific configurations** (e.g., `config/app.php` values that vary by locale, region, or user segment).
- You need **automatic fallback chains** for configs (e.g., `es_MX` → `es` → `en`) without manual merging logic.
- Your team lacks bandwidth to build a **custom localization layer** for configs (e.g., nested arrays, dynamic loading).
- You’re using **Laravel 8+** and want to avoid reinventing the wheel for config localization.
- Your configs are **file-based** (not database-driven) and require **runtime flexibility** (e.g., per-request overrides).
- You need to **support 10+ locales** without manual config duplication.
- Your product requires **dynamic theming** or **feature flags** tied to user language/region.
### **Look Elsewhere If**:
- You need **database-driven configs**: This package is file-based; consider **Spatie’s `laravel-config-array`** or a CMS integration (e.g., Strapi, Contentful) for dynamic updates.
- Your configs are **static** (no language/region variation): Use Laravel’s built-in `config()` helper.
- You’re using **non-Laravel PHP** (e.g., Symfony, Lumen without Laravel’s core): Evaluate framework-native solutions (e.g., Symfony’s `ParameterBag`).
- You require **real-time config updates**: File-based systems need cache invalidation (e.g., `config:clear`). For live updates, pair with **Redis** or a **config service** (e.g., LaunchDarkly, Unleash).
- Your team needs **advanced validation** for configs: This package focuses on localization; combine with **VentureCraft’s `reverb`** or **Spatie’s `laravel-validation-rules`** for schema validation.
- You’re on **Laravel < 8**: The package drops support for older versions (e.g., Laravel 10 is unsupported in v2.x).
- Your configs are **highly sensitive** (e.g., secrets): Avoid storing them in PHP files; use environment variables or a secrets manager.
---
## How to Pitch It (Stakeholders)
### **For Executives (Business/Strategy)**
*"This package lets us ship localized configurations—like region-specific APIs, legal disclaimers, or UI elements—**without custom development**, accelerating our [Q3 international expansion] by **40%**. For example:
- **Spanish users** automatically see `config('services.payment.gateway.es')` for localized payment processing.
- **EU compliance** is enforced via `config('privacy.gdpr.enabled')` without manual checks.
- **A/B testing** for language-specific CTAs (e.g., `config('ui.cta_button.fr')`) reduces dev overhead.
**Why It’s a No-Brainer**:
- **MIT License**: No vendor lock-in; maintained by the Laravel community.
- **Cost Savings**: Eliminates the need for custom tooling or translation service integrations.
- **Scalability**: Supports **100+ locales** with zero additional infrastructure.
- **Speed**: Cuts localization setup time from **months to days**.
**Ask**: Should we prioritize this for [Product X]’s global launch to reduce risk and cost?"
---
### **For Engineering (Technical)**
*"The `laravel-lang/config` package provides a **zero-boilerplate** way to manage language-specific configs using Laravel’s existing `config()` helper. Here’s the breakdown:
**Key Features**:
- **Automatic Fallbacks**: Load configs like `config('app.locale_aware_setting')` with chains (e.g., `es_MX` → `es` → `default`).
- **File-Based**: No database overhead; edits trigger cache rebuilds (`config:clear`).
- **Laravel-Native**: Integrates with service providers, facades, and caching.
- **Testable**: Mock configs in PHPUnit without touching files.
- **Future-Proof**: Works with Laravel’s upcoming localization improvements.
**Integration Steps**:
1. Publish configs:
```bash
php artisan vendor:publish --provider="LaravelLangConfigServiceProvider"
config/app.php:
'providers' => [
LaravelLangConfigServiceProvider::class,
],
$endpoint = config('services.stripe.endpoint'); // Falls back to default
Tradeoffs:
config:clear after updates (or automate with Git hooks).reverb for schema validation.Alternatives:
| Solution | Pros | Cons | Fit for laravel-lang/config |
|---|---|---|---|
| Custom Solution | Full control | High maintenance cost | ❌ No |
Spatie’s laravel-translation |
Great for models | Not for configs | ❌ No |
Symfony’s ParameterBag |
Robust | Overkill for Laravel | ❌ No |
| Database-Driven | Real-time updates | Complex setup | ❌ No (unless paired with Redis) |
Risk Mitigation:
APP_LOCALE)."*"This package enables dynamic, language-specific UI elements without hardcoding, giving us flexibility for:
config('ui.cta_button.es') = '¡Compra Ahora!' automatically.config('ui.theme.colors.dark_mode') for locale-aware styling.config('ui.layout.es')) without code changes.Workflow:
config/locales/es/ui.php.config:clear (or automate with Git hooks).Example:
// config/locales/en/ui.php
'cta_button' => 'Buy Now',
// config/locales/es/ui.php
'cta_button' => '¡Compra Ahora!',
// In Blade:
<button>{{ config('ui.cta_button') }}</button>
Tools to Pair With:
.json).*"This package adds no infrastructure overhead but requires:
config:clear after config file updates (or automate with Git hooks).php artisan config:clear
APP_LOCALE is set in .env (e.g., APP_LOCALE=es_MX)..env.local for environment-specific configs.How can I help you explore Laravel packages today?