PHP code example of storinka / invoke-service-container

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

    

storinka / invoke-service-container example snippets


use Invoke\Di\ServiceContainer;

$container = new ServiceContainer();

$container->singleton(AbstractService::class, Service::class);
$container->singleton(AbstractService::class, new Service());
$container->singleton(AbstractService::class, fn() => new Service());

$service = $container->get(AbstractService::class);