PHP code example of blackcube / injector

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

    

blackcube / injector example snippets


use Blackcube\Injector\Injector;

// In your bootstrap or container setup
Injector::init($container);

use Blackcube\Injector\Injector;

// Get a service
$logger = Injector::get(LoggerInterface::class);

// Check availability
if (Injector::has(CacheInterface::class)) {
    $cache = Injector::get(CacheInterface::class);
}

// config/common/bootstrap.php (shipped with package)
static function (ContainerInterface $container): void {
    Injector::init($container);
};