PHP code example of icanboogie / bind-symfony-dependency-injection

1. Go to this page and download the library: Download icanboogie/bind-symfony-dependency-injection 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/ */

    

icanboogie / bind-symfony-dependency-injection example snippets




use function ICanBoogie\Service\ref;

$reference = ref('a_callable_service');
$result = $reference(1, 2, 3);

$reference = ref('a_service');
$service = $reference->resolve();
$service->do_something();



/* @var $app \ICanBoogie\Application */
/* @var $container \Symfony\Component\DependencyInjection\Container */

$container = $app->container;
$service = $container->get('a_service');
$service->do_something();



use ICanBoogie\Service\ServiceProvider;

/* @var $proxy \ICanBoogie\Binding\SymfonyDependencyInjection\ContainerFactory */

$proxy = ServiceProvider::defined();
$container = $proxy->container;



// config/container.php

use ICanBoogie\Binding\SymfonyDependencyInjection\ConfigBuilder;
use ICanBoogie\Binding\SymfonyDependencyInjection\Extension\ApplicationExtension;

return fn(ConfigBuilder $config) => $config
    ->add_extension(ApplicationExtension::class)
    ->enable_caching();