PHP code example of reliv / zf-config-factories

1. Go to this page and download the library: Download reliv/zf-config-factories 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/ */

    

reliv / zf-config-factories example snippets


// Example of constructor injection with the service name being the same as its class name:
'service_manager' => [
    'config_factories' => [
        'App\Email\EmailService' => [
            'arguments' => [
                'Name\Of\A\Service\I\Want\To\Inject',
                'Name\Of\A\AnotherService\I\Want\To\Inject'
            ],
        ]
    ]
]

// Use 'dependencies' instead of 'service_manager' here if using Zend Expressive
'service_manager' => [

    // This is a special config key that zf-config-factories reads.
    'config_factories' => [
    
        // This is the name of the service that we are defining.
        'EmailTemplateApi' => [
        
            /**
             * This is the service's class name.
             * Not          'Name\Of\A\Service\I\Want\To\Inject',
                'Name\Of\A\Service\I\Want\To\Inject2',
                'Name\Of\A\Service\I\Want\To\Inject3',
                'Name\Of\A\Service\I\Want\To\Inject4',
                ['literal' => 'aLiteralValueNotAService'],
                ['from_config' => 'keyOfValueFromZfConfigIWantToReadAndInjectHere'],
                ['from_config' => ['path','to','a','deep','nested','zf','config','key']],
                'Name\Of\A\Service\I\Want\To\Inject5',
            ],
            
            /** 
             * This is an array of setters to call mapped to service names to inject into each setter.
             * Not