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

Laminas Config Laravel Package

laminas/laminas-config

Abandoned Laminas library for managing application configuration. Provides config containers and utilities (e.g., reading/merging structured config) used across Laminas/Zend-style apps. No further development; see Laminas TSC minutes for details.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer (composer require laminas/laminas-config) and creating a config.php file that returns an associative array (e.g., database credentials, app settings). Use Laminas\Config\Config to wrap the array and access values like $config->database->host. The API is intentionally simple: use dot notation ($config->app->debug) or array access ($config['app']['debug']) to traverse nested structures. The first use case is usually loading environment-specific config: merge local overrides (e.g., config.local.php) with a base config using Config::fromFile() and Config::fromArray().

Implementation Patterns

  • Immutable Defaults + Overridable Overrides: Load a base config with Config::fromFile('config.php'), then layer environment-specific changes using Config::set() or Config::toArray() + Config::fromArray() to merge.
  • Lazy-Loading via Config Aggregation: Combine multiple config files (e.g., routes.php, services.php) into a single Config object by iterating over files and merging with Config::setFromProperty() or manual array merging before wrapping.
  • Service Container Integration: Feed Config objects directly into factory classes—e.g., pass $config->db to a PDO factory. This decouples configuration from instantiation logic.
  • Typed Access with Casting: Use Config::offsetGet() or cast to primitive types ((string) $config->app->timeout) to avoid type surprises at runtime.

Gotchas and Tips

  • No __isset() Support: isset($config->missing->key) throws a notice. Always use $config->offsetExists('missing') or check via array_key_exists() after converting to array.
  • Nested Arrays Convert to Objects: Config values become ArrayObject instances—so gettype($config->app) is object, not array. To force arrays, call $config->toArray() before processing.
  • Merge Strategy Is Shallow by Default: Overlapping keys in merged configs replace entire nested arrays (e.g., merging ['db' => ['host' => 'a']] into ['db' => ['port' => 3306]] loses port). Use Config::setFromProperty() per-level or pre-merge arrays with array_replace_recursive() first.
  • Deprecated but Production-Ready: The package is archived, but its core functionality is stable and battle-tested. For new projects, consider alternatives like symfony/config, but this remains safe for legacy/maintained apps where minimal dependencies matter.
  • Extend with ConfigInterface: To add behavior (e.g., validation), implement Laminas\Config\AggregatorInterface or subclass Laminas\Config\Config and override offsetGet() for custom defaults.
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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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