PHP code example of fast-forward / container

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

    

fast-forward / container example snippets


use FastForward\Container\ContainerInterface;
use FastForward\Container\container;
use FastForward\Config\ArrayConfig;

$config = new ArrayConfig([
    ContainerInterface::class => [
        SomeServiceProvider::class, // strings will be initialized with a new call
        SomePsr11Container::class, // strings should be initializable with a simple new call
        new OtherServiceProvider('withArgument'), // objects that implement Interop\Container\ServiceProviderInterface
        new ServiceManager($dependencies), // objects that implement Psr\Container\ContainerInterface
    ],
]);

$container = container($config);

// or using the container function directly with a configuration variadic
// $container = container(
//     SomeServiceProvider::class,
//     SomePsr11Container::class,
//     new ApplicationConfig(), // that implements ConfigInterface with the ContainerInterface key
//     new OtherServiceProvider('withArgument'),
//     new ServiceManager($dependencies),
// );

// Retrieve service
$service = $container->get(SomeService::class);