PHP code example of samburns / dirty-needle

1. Go to this page and download the library: Download samburns/dirty-needle 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/ */

    

samburns / dirty-needle example snippets



return array(
    'dirty-needle' => array(
        '@dependency' => array(
            'class' => '\Dependency'
        ),
        '@class-with-dependency' => array(
            'class' => '\ClassWithDependency',
            'arguments' => array(
                '@dependency'
            )
        ),
    ),
);

$diContainer = \DirtyNeedle\DiContainer()::getInstance();
$diContainer->addConfigFile('/path/to/config.php');
$classWithDependency = $diContainer->get('class-with-dependency');

$diContainer->set('service-id', $mockObject);

$diContainer->reset();