PHP code example of mnapoli / php-di-zf2

1. Go to this page and download the library: Download mnapoli/php-di-zf2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mnapoli / php-di-zf2 example snippets


    // ...
    'modules' => [
        ...
        'DI\ZendFramework2',
        ...
    ],

    'service_manager' => [
        // ...
        'factories' => [
            'DI\Container' => 'DI\ZendFramework2\Service\DIContainerFactory',
        ],
    ],

return [
    'phpdi-zf2' => [
        ...
    ]
];

return [
    'phpdi-zf2' => [
        'definitionsFile' => realpath(__DIR__ . '/../my.custom.def.config.php'),
    ]
];

return [
    'phpdi-zf2' => [
        'useAnntotations' => true,
    ]
];

return [
    'phpdi-zf2' => [
        'cache' => [
            'adapter' => 'apcu',
            'namespace' => 'your_di_cache_key',
        ],
    ]
];

return [
    'phpdi-zf2' => [
        'cache' => [
            'adapter' => 'filesystem',
            'namespace' => 'your_di_cache_key',
            'directory' => 'your_cache_directory', // default value is data/php-di/cache
        ],
    ]
];

return [
    'phpdi-zf2' => [
        'cache' => [
            'namespace' => 'your_di_cache_key',
            'adapter' => 'redis',
            'host' => 'localhost', // default is localhost
            'port' => 6379, // default is 6379
            'database' => 1, // default is the same as phpredis default
        ],
    ]
];

return [
    'phpdi-zf2' => [
        'cache' => [
            'adapter' => 'memcached',
            'host' => 'localhost', // default is localhost
            'port' => 11211, // default is 11211
        ],
    ]
];
json
{
    "hp-di/php-di": "*",
        "php-di/zf2-bridge": "*"
    }
}

php public/index.php php-di-clear-cache