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

Php Settings Container Laravel Package

chillerlan/php-settings-container

Lightweight settings container for PHP that decouples configuration logic from your application. Provides a SettingsContainerInterface with property-hook style access (for PHP < 8.4). Not a dependency injection container.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Decoupling Configuration Logic: Enables clean separation of settings management from business logic, reducing tight coupling in Laravel applications (e.g., separating config/app.php from service classes).
  • Immutable Settings Objects: Supports feature flags, environment-specific configurations, or A/B testing payloads where immutability prevents accidental modifications.
  • Build vs. Buy: Avoids reinventing a custom settings manager while offering more flexibility than Laravel’s native Config facade (e.g., dynamic trait-based behavior).
  • Use Cases:
    • Dynamic Feature Toggles: Load toggle rules from JSON/DB and validate them via traits (e.g., FeatureToggleContainer with set_enabled() hooks).
    • Multi-Tenant Configurations: Merge tenant-specific settings with global defaults using fromIterable().
    • Validation/Transformation: Apply business logic during property assignment (e.g., set_api_key() hashing sensitive values).
    • Serialization/Deserialization: Replace Laravel’s cache:config with JSON-based settings stored in Redis or S3.

When to Consider This Package

  • Adopt if:
    • Your Laravel app needs immutable, typed configurations (e.g., for microservices or serverless functions).
    • You require trait-based extensibility (e.g., plugging in validation, logging, or caching behaviors).
    • You’re managing complex nested settings (e.g., per-region API endpoints with fallback logic).
    • You want to avoid Laravel’s Config facade for performance-critical paths (e.g., high-frequency setting lookups).
  • Look Elsewhere if:
    • You only need simple key-value configs (use Laravel’s Config or env()).
    • Your team lacks PHP 8.4+ (property hooks add complexity for older versions).
    • You’re using dependency injection (this is not a DI container; pair with Laravel’s container if needed).
    • You need runtime configuration reloading (this package prioritizes immutability over hot-reload).

How to Pitch It (Stakeholders)

For Executives: "This package lets us treat app configurations as first-class objects—immutable, type-safe, and extensible via reusable traits. For example, we could dynamically load feature flags from a JSON file, validate them with custom logic (e.g., rate limits), and inject them into services without polluting the global config. It’s like Laravel’s Config facade but with superpowers for complex scenarios, reducing tech debt in multi-tenant or serverless deployments."

For Engineers: *"Replace scattered config() calls with a typed, immutable container. Key benefits:

  • Traits for behavior: Add validation, logging, or caching to settings without modifying core logic (e.g., use HashesApiKeys).
  • JSON/array interop: Load settings from files, APIs, or databases seamlessly ($container->fromJSON($payload)).
  • PHP 8.4 hooks: Leverage native property hooks for side effects (e.g., auto-hashing passwords) while falling back to magic methods for older PHP.
  • Performance: Avoids the overhead of Laravel’s Config facade for high-frequency access.

Example: Instead of:

if (config('features.new_ui.enabled') && auth()->user()->isPremium()) {
    // ...
}

Use:

$settings = new FeatureSettings(['enabled' => true]);
if ($settings->isEnabledForPremiumUser(auth()->user())) { ... }

Tradeoff: Slight learning curve for traits/magic methods, but pays off in maintainability."*

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation