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 PHP settings container to keep configuration logic out of your app (not a DI container). Provides a SettingsContainerInterface with “property hook”-style access for PHP < 8.4, plus sane defaults for organizing and retrieving settings objects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Decoupling Configuration Logic: Enables separation of settings management from business logic, improving modularity and maintainability in Laravel applications (e.g., decoupling config/app.php from service classes).
  • Immutable Settings Objects: Supports feature development for read-only configurations (e.g., API endpoints, feature flags) where immutability prevents accidental modifications.
  • Build vs. Buy: Replaces custom configuration managers or DI containers for settings, reducing technical debt and leveraging a battle-tested, lightweight solution.
  • Use Cases:
    • Dynamic Configuration: Load settings from JSON/arrays at runtime (e.g., feature toggles, environment-specific overrides).
    • Trait-Based Extensibility: Plug in third-party traits (e.g., validation rules, logging defaults) without inheritance hierarchies.
    • Serialization/Deserialization: Standardize how settings are stored/retrieved (e.g., caching, database storage).
    • Validation Hooks: Add custom logic (e.g., type conversion, default values) via set_*/get_* methods or PHP 8.4+ property hooks.

When to Consider This Package

  • Adopt When:
    • Your Laravel app needs immutable, structured settings (e.g., replacing flat arrays or global variables).
    • You require runtime configuration flexibility (e.g., loading settings from JSON/YAML without DI containers).
    • You want to avoid DI complexity for simple settings management (e.g., no need for binding interfaces).
    • Your team uses traits for reusable logic (e.g., shared validation, logging defaults across services).
    • You need serialization support (e.g., caching settings in Redis or storing in a database).
  • Look Elsewhere If:
    • You need dependency injection (use Laravel’s built-in container or Illuminate/Container).
    • Your settings require complex lifecycle management (e.g., event listeners, dynamic reloading).
    • You’re on PHP < 8.4 and need property hooks (use a fork or alternative like spatie/array-to-object).
    • You prefer environment variable parsing (use vlucas/phpdotenv or Laravel’s env() helper).
    • Your settings are highly dynamic (e.g., real-time updates) and require reactive patterns (consider event-driven architectures).

How to Pitch It (Stakeholders)

For Executives: "This package lets us manage application settings as immutable objects—like a structured, type-safe alternative to PHP arrays or global configs. It decouples settings from business logic, making our code more maintainable and easier to test. For example, we can load feature flags from JSON at runtime without bloating our DI container. It’s lightweight, integrates with Laravel’s ecosystem, and reduces technical debt by avoiding custom solutions."

For Engineers: *"This is a SettingsContainer for PHP/Laravel that:

  • Replaces flat configs/arrays with typed, immutable objects (e.g., new AppSettings(['debug' => true])).
  • Supports traits for reusable logic (e.g., validation, defaults) without inheritance.
  • Handles serialization (JSON, arrays, PHP serialize) out of the box—great for caching or storage.
  • Works with PHP 8.4+ property hooks for advanced get/set logic (or falls back to magic methods).
  • Avoids DI overhead for simple settings, keeping our container lean.

Use case: Replace config('app.debug') calls with $settings->debug in services, with runtime overrides from JSON. Traits can add validation or logging defaults without polluting service classes.*

Key Benefits:

  • Cleaner code: No more config() calls scattered across services.
  • Testability: Immutable objects are easier to mock/stub.
  • Extensibility: Plug in third-party traits or custom logic via set_*/get_* methods.
  • Performance: Lightweight (~500 LOC), no dependencies beyond PHP 8.4."
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi