zendframework/zend-auradi-config
Zend Auradi Config integrates Auradi-style configuration loading into Zend Framework apps. Provides utilities to read, merge, and manage environment-specific config sources for cleaner, modular application configuration.
Start by installing the package via Composer: composer require zendframework/zend-auradi-config. Then, create a Zend-style config array (e.g., config.global.php) with service definitions and parameters—structured like:
return [
'dependencies' => [
'invokables' => [
SomeInterface::class => SomeService::class,
],
'factories' => [
AnotherService::class => AnotherServiceFactory::class,
],
],
'parameters' => [
'database.dsn' => 'mysql:host=localhost;dbname=test',
'debug' => false,
],
];
Use Zend\AuraDi\Config\ConfigResource to load and merge config files into an Aura\Di\ContainerBuilder:
$builder = new Aura\Di\ContainerBuilder();
$builder->addConfig(new Zend\AuraDi\Config\ConfigResource($configArray));
$container = $builder->newInstance();
First use case: bootstrapping a small app with environment-specific config overrides (e.g., config.local.php) without writing DI code manually.
config.global.php) first, then merge environment-specific files (e.g., config.local.php, config.development.php) using ArrayObject or custom merging logic. ConfigResource handles Zend-style dependencies and parameters keys directly.invokables, factories, methods, and objects under dependencies, mirroring Zend Framework conventions—ideal for teams already familiar with Zend skeleton apps.parameters key, then inject them into services using @param $parameterName in factory signatures or constructor injection via get() in factory classes.dependencies and parameters. Aggregate them before passing to ConfigResource for modular, scalable DI setup.laminas/laminas-auradi-config if migrating to Laminas (same API, newer support).dependencies and parameters keys; typos or incorrect nesting (e.g., services instead of dependencies) silently fail or throw during container instantiation.factories that rely on autowiring, ensure factory class names match Aura.Di’s expectations—ConfigResource does not auto-detect factory interfaces or resolve ambiguous signatures.parameters) overwrite entirely. Use recursive merge helpers if needed.ContainerBuilder::$debug = true to see generated service definitions and catch invalid factory/resolver references early.ConfigResource to add custom config keys (e.g., di_extensions) by overriding __invoke() and passing extra config to $builder->addConfig().How can I help you explore Laravel packages today?