Skip to content

Instantly share code, notes, and snippets.

@basz
Created May 1, 2012 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basz/2568952 to your computer and use it in GitHub Desktop.
Save basz/2568952 to your computer and use it in GitHub Desktop.
DI parameters woes
<?php
return array(
'di' => array(
'definition' => array(
'class' => array(
'Zend\Log\Logger' => array(
'addWriter' => array(
'writer' => array('required' => true),
)
),
'Zend\Cache\Storage\Adapter\AdapterInterface' => array(
'instantiator' => array(
'Zend\Cache\StorageFactory',
'factory',
),
),
'Zend\Cache\StorageFactory' => array(
'methods' => array(
'factory' => array(
'cfg' => array(
'required' => true,
),
),
),
),
),
),
'instance' => array(
'alias' => array(
'my-service' => 'My\Service',
'my-service-configuration' => 'My\ServiceOptions',
'my-logger' => 'Zend\Log\Logger',
'my-log-writer' => 'Zend\Log\Writer\Stream',
'my-cache-adapter' => 'Zend\Cache\Storage\Adapter\AdapterInterface',
),
'My\Service' => array(
'parameters' => array(
'options' => 'my-service-configuration',
'logger' => 'my-logger',
'cache' => 'my-cache-adapter',
),
),
'my-logger' => array(
'parameters' => array(
'writer' => 'my-log-writer',
),
),
'my-log-writer' => array(
'parameters' => array(
'streamOrUrl' => __DIR__ . '/../../../data/logs/my.log',
),
),
'my-cache-adapter' => array(
'parameters' => array(
'cfg' => array(
'adapter' => array(
'name' => 'filesystem',
'options' => array(
'ttl' => 24*3600,
'cacheDir'=> realpath(__DIR__ . '/../../../data/cache'),
'namespace' => 'my-space',
),
),
'plugins' => array(
/* 'serializer', disabled because bugs */
),
),
),
),
'my-service-configuration' => array(
'parameters' => array(
'options' => array(
... bunch of options ...
),
),
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment