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

Laravel Lang: Config provides configuration resources for the Laravel Lang ecosystem. Install via Composer to keep your app aligned with Laravel Lang defaults and updates, with MIT licensing and community support available.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel-Native Localization: Perfectly aligns with Laravel’s existing config() helper and service container, requiring minimal architectural disruption. Leverages Laravel’s built-in caching (config:clear) and service provider patterns.
  • File-Based Configs: Ideal for static or semi-static configurations that vary by locale/region but don’t require real-time updates. Avoids database bloat while maintaining flexibility.
  • Fallback Chains: Supports hierarchical fallbacks (e.g., es_MXesen), reducing duplication and simplifying maintenance for multilingual apps.
  • Composability: Integrates seamlessly with other Laravel-Lang packages (e.g., laravel-lang/translator) and Spatie’s laravel-data (used internally for DTOs), enabling a cohesive localization stack.

Integration Feasibility

  • Low Friction: Designed for Laravel 8+ (with explicit support for Laravel 11–13), requiring only:
    • Service provider registration.
    • Config file publishing (vendor:publish).
    • Minimal facade usage (e.g., LaravelLangConfigServiceProvider).
  • Backward Compatibility: Supports incremental adoption—existing configs remain unchanged until explicitly migrated to locale-aware files (e.g., config/locales/en/app.php).
  • IDE Support: Includes helper files for autocompletion (configurable via VENDOR_PATH environment variable).

Technical Risk

  • Cache Invalidation: File-based configs require config:clear after updates, which may introduce deployment friction. Mitigation: Automate with Git hooks or CI/CD scripts.
  • Laravel Version Lock: Drops support for Laravel <8 (v2.x) and <10 (v1.x), requiring version alignment. Critical for legacy apps.
  • Limited Validation: No built-in schema validation for configs (e.g., ensuring config('services.stripe.key') is non-empty). Workaround: Pair with reverb or custom validation.
  • Real-Time Constraints: Not suitable for dynamic configs (e.g., user-specific overrides). Workaround: Cache configs in Redis or use a hybrid approach (e.g., database for dynamic values, files for static).
  • Namespace Pollution: Publishes configs to config/locales/, which may conflict with existing directory structures. Mitigation: Customize publish paths via service provider.

Key Questions

  1. Locale Strategy:
    • How will locales be determined (e.g., user preference, geolocation, browser Accept-Language)? The package relies on Laravel’s App::currentLocale() or custom logic.
    • Are there edge cases (e.g., right-to-left languages, fallback priorities) that need explicit handling?
  2. Performance:
    • Will configs be cached globally or per-request? The package uses Laravel’s default config caching, which may not support per-request overrides.
    • What’s the expected config file size? Large files could impact config:clear performance.
  3. Deployment:
    • How will config updates be deployed (e.g., zero-downtime)? File-based systems may require rolling restarts or cache invalidation strategies.
    • Is config:clear compatible with your CI/CD pipeline (e.g., Docker, serverless)?
  4. Testing:
    • How will locale-specific configs be tested? The package supports mocking, but complex fallback chains may need dedicated test cases.
  5. Alternatives:
    • Have you evaluated database-driven configs (e.g., Spatie’s laravel-config-array) or external services (e.g., LaunchDarkly) for dynamic use cases?
  6. Maintenance:
    • Who will own config file updates (e.g., developers, translators)? File-based systems require developer access.
    • How will config drift (e.g., missing locales) be monitored?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Optimized for Laravel 8+ apps using:
    • Service container (for dependency injection).
    • Facades (e.g., config() helper).
    • Artisan commands (config:clear).
    • Blade templates (for dynamic locale-aware UI).
  • Complementary Packages:
    • Laravel-Lang/Translator: For language-specific translations (e.g., trans('messages.welcome')).
    • Spatie/Laravel-Data: Used internally for DTOs (no direct user impact).
    • Laravel Breeze/Jetstream: For auth-driven locale switching.
  • Non-Laravel Stacks:
    • Symfony: Not directly compatible; consider Symfony’s ParameterBag or yaml configs.
    • Lumen: Limited support; may require custom service providers.
    • Monolithic PHP: High integration effort due to lack of Laravel’s service container.

Migration Path

  1. Assessment Phase:
    • Audit existing configs (config/ directory) to identify locale-aware candidates (e.g., services.stripe.endpoint, legal.terms).
    • Define fallback chains (e.g., es_MXesen) and document in README.md.
  2. Setup:
    • Install the package:
      composer require laravel-lang/config
      
    • Publish configs:
      php artisan vendor:publish --provider="LaravelLangConfigServiceProvider" --tag="config"
      
    • Register the service provider in config/app.php:
      'providers' => [
          LaravelLangConfigServiceProvider::class,
      ],
      
  3. Incremental Migration:
    • Phase 1: Migrate static configs (e.g., app.php, services.php) to locale-aware files:
      config/
      ├── locales/
      │   ├── en/
      │   │   ├── app.php
      │   │   └── services.php
      │   └── es/
      │       ├── app.php
      │       └── services.php
      └── app.php (default fallbacks)
      
    • Phase 2: Update references in code to use config('app.locale_aware_setting').
    • Phase 3: Implement locale detection logic (e.g., middleware to set App::setLocale()).
  4. Testing:
    • Write unit tests for fallback chains using Config::shouldReceive('get').
    • Test edge cases (e.g., missing locales, invalid keys).
  5. Deployment:
    • Add php artisan config:clear to deployment scripts (or automate with Git hooks).
    • Monitor cache performance post-migration.

Compatibility

  • Laravel Versions: Officially supports 11–13 (v2.x). Laravel 10 is unsupported in v2.x (use v1.x if needed).
  • PHP Versions: Requires PHP 8.0+ (aligned with Laravel’s minimum).
  • Existing Configs: Non-locale-aware configs remain unchanged and act as defaults. Example:
    // config/app.php (default)
    'timezone' => 'UTC',
    
    // config/locales/es/app.php (override)
    'timezone' => 'America/Mexico_City',
    
  • Third-Party Packages: May conflict if they assume flat config structures. Mitigation: Use config merging or namespacing (e.g., package_name.*).

Sequencing

  1. Prerequisites:
    • Laravel 8+ (preferably 11+ for full feature support).
    • PHP 8.0+.
    • Composer installed.
  2. Dependencies:
    • Install before migrating configs to avoid breaking changes.
    • Pair with laravel-lang/translator if using language-specific translations.
  3. Parallel Work:
    • Develop locale detection logic (e.g., middleware) concurrently with config migration.
    • Update documentation and runbooks for new config structure.
  4. Post-Integration:
    • Implement monitoring for config cache misses or invalidation failures.
    • Train developers on the new structure (e.g., config('locales.es.app.timezone')).

Operational Impact

Maintenance

  • Config Management:
    • Pros: File-based edits are version-controlled (Git) and auditable. No database migrations required.
    • Cons: Manual config:clear needed after updates. Mitigation:
      • Automate with post-commit hooks:
        git commit -m "Update Spanish configs" && php artisan config:clear
        
      • Use CI/CD pipelines to invalidate cache on config file changes.
    • Ownership: Developers must manage config files, which may introduce merge conflicts in collaborative environments. Solution: Enforce a naming convention (e.g., config/locales/{locale}/{file}.php) and use Git submodules for shared configs.
  • Locale Updates:
    • Adding new locales requires creating new directories/files. Tooling: Script the process:
      #!/bin/bash
      mkdir -p config/locales/$LOCALE
      cp -r config/locales/en/* config/locales/$LOCALE/
      
    • Fallback chains must be documented to avoid runtime errors.

Support

  • Debugging:
    • Common Issues:
      • `config('none
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor