PHP code example of jangolle / slim-symfony-container
1. Go to this page and download the library: Download jangolle/slim-symfony-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/ */
jangolle / slim-symfony-container example snippets
declare(strict_types=1);
use JanGolle\SlimSymfonyContainer\ContainerManager;
use JanGolle\SlimSymfonyContainer\Loader\SlimDefaultServicesInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
$containerManager = new ContainerManager();
$container = new ContainerBuilder();
$container = $containerManager->resolveContainer($container, new SlimDefaultServicesInjection());
$app = new \Slim\App($container);
//setup routes or something
$app->run();
declare(strict_types=1);
use JanGolle\SlimSymfonyContainer\ContainerManager;
use JanGolle\SlimSymfonyContainer\Loader\SlimDefaultServicesInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
$containerManager = new ContainerManager();
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/path/to/config'));
$loader->load('services.yaml');
$container = $containerManager->resolveContainer($container, new SlimDefaultServicesInjection());
$app = new \Slim\App($container);
//setup routes or something
$app->run();
$container = new YourCustomContainer($fullOfParams);//instance of Symfony\Component\DependencyInjection\ContainerBuilder
$container = $containerManager->resolveContainer($container, new SlimDefaultServicesInjection());
$container = $containerManager->resolveContainer(YourCustomContainer::class, new SlimDefaultServicesInjection());