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

Config Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel-Native Integration: Designed specifically for Laravel’s config system, leveraging its existing config() helper, service providers, and caching mechanisms. Aligns perfectly with Laravel’s architecture (e.g., config/app.php bindings, facades).
  • Localization-First Design: Built to handle nested, language-specific configurations with automatic fallback chains (e.g., es_MXesen), reducing boilerplate for multilingual apps.
  • Modularity: Supports incremental adoption—start with a single locale (e.g., config('app.name.es')) and scale to full localization without refactoring.
  • Facade Pattern: Replaces static classes with Laravel’s facade (LaravelLangConfig), improving testability and IDE support.

Integration Feasibility

  • Low Friction: Requires only:
    1. Composer install (composer require laravel-lang/config).
    2. Service provider binding in config/app.php.
    3. Publishing configs (php artisan vendor:publish --provider="LaravelLangConfigServiceProvider").
  • Backward Compatibility: Works alongside existing Laravel configs; no breaking changes to core functionality.
  • Dynamic Loading: Supports runtime overrides (e.g., per-request locale switching via middleware).
  • IDE-Friendly: Generates IDE helper files (configurable via VENDOR_PATH env var) for autocompletion.

Technical Risk

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).

Key Questions

  1. Locale Strategy:
    • How will locales be determined (user preference, geolocation, or explicit selection)?
    • Do we need runtime locale switching (e.g., per-request) or static per-app configs?
  2. Config Scope:
    • Will configs be global (e.g., config('app.locale')) or user-specific (e.g., config('user_prefs.theme'))?
    • Do we need database-backed configs for dynamic updates (this package is file-only)?
  3. Fallback Behavior:
    • Should fallbacks be strict (fail if no match) or lenient (default to en)?
    • Example: es_MXesen vs. es_MXes (no default).
  4. Validation Needs:
    • Are configs schema-validated (e.g., required fields, types)? If so, pair with venturecraft/reverb.
  5. Deployment Workflow:
    • How will config updates be deployed (manual config:clear, CI/CD, or live reload)?
    • Will configs be version-controlled (Git) or managed externally (e.g., a CMS)?
  6. Testing:
    • How will locale-specific configs be tested (mocking, environment variables)?
    • Example: Testing config('services.stripe.endpoint.eu') in CI.
  7. Alternatives:
    • Why not use Laravel’s built-in config() with manual merging logic?
    • Why not Spatie’s laravel-translation (better for models) or Symfony’s ParameterBag?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Optimized for Laravel 8–13 (PHP 8.0+). Leverages:
    • Service providers (LaravelLangConfigServiceProvider).
    • Facades (LaravelLangConfig).
    • Caching (config() helper).
    • Artisan commands (vendor:publish, config:clear).
  • PHP Compatibility: No external dependencies beyond Laravel core and Composer.
  • Tooling Integration:
    • IDE Helpers: Auto-generated for PhpStorm/VSCode via VENDOR_PATH.
    • CI/CD: Supports automated config publishing and cache invalidation.
    • Testing: Mockable via Laravel’s Config facade or config() helper.

Migration Path

  1. Assessment Phase (1–2 days):
    • Audit existing configs to identify locale-variant values (e.g., API endpoints, legal text).
    • Example: config('services.stripe.endpoint')config('services.stripe.endpoint.{locale}'.
    • Document fallback rules (e.g., es_MXesen).
  2. Pilot Phase (1 week):
    • Install package in a non-production environment.
    • Publish configs: php artisan vendor:publish --provider="LaravelLangConfigServiceProvider".
    • Migrate 1–2 locale-sensitive configs (e.g., app name, contact email).
    • Test fallback behavior with missing locales.
  3. Incremental Rollout (2–4 weeks):
    • Migrate configs in batches (e.g., API endpoints → UI strings → feature flags).
    • Update routes, models, and views to use config('locale_key.value').
    • Example:
      // Before
      Route::get('/contact', function () {
          return 'Email: contact@example.com';
      });
      
      // After
      Route::get('/contact', function () {
          return 'Email: ' . config('app.contact_email');
      });
      
  4. Production Cutover (1 day):
    • Deploy configs to production.
    • Automate cache invalidation (e.g., Git hook to run config:clear).
    • Monitor for missing config errors (log config() calls with invalid keys).

Compatibility

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).

Sequencing

  1. Pre-requisites:
    • Laravel 11–13 installed.
    • Composer configured for private packages (if needed).
    • Basic understanding of Laravel’s config() system.
  2. Core Integration:
    • Install package: composer require laravel-lang/config.
    • Bind service provider in config/app.php:
      'providers' => [
          LaravelLangConfigServiceProvider::class,
      ],
      
    • Publish configs: php artisan vendor:publish --provider="LaravelLangConfigServiceProvider".
  3. Configuration:
    • Define locale-specific configs in config/locales/{locale}.php (e.g., es.php, fr.php).
    • Example:
      // config/locales/es.php
      return [
          'app' => [
              'name' => 'Mi App',
              'contact_email' => 'contacto@miapp.es',
          ],
          'services' => [
              'stripe' => [
                  'endpoint' => 'https://api.stripe.eu/v1',
              ],
          ],
      ];
      
  4. Fallback Setup:
    • Configure fallback chain in config/lang_config.php:
      'fallbacks' => [
          'es_MX' => ['es', 'en'],
          'fr_CA' => ['fr', 'en'],
      ],
      
  5. Usage:
    • Access configs with config('locale_key.value'):
      $appName = config('app.name'); // Falls back to default locale
      $euEndpoint = config('services.stripe.endpoint.eu'); // Explicit locale
      
  6. Advanced Features (Optional):
    • Dynamic locale switching via middleware:
      public function handle(Request $request, Closure $next) {
          config(['app.locale' => $request->header('Accept-Language')]);
          return $next($request);
      }
      
    • Custom config paths (e
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui