/** * @return \Nonogram\Solver\SolverJ54 */ private function initContainer() { $this->container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); $loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($this->container, new \Symfony\Component\Config\FileLocator(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Nonogram' . DIRECTORY_SEPARATOR . 'Config'))); $loader->load('container.yml'); $this->container->compile(); }
/** * @return \ProjectServiceContainer|\Symfony\Component\DependencyInjection\Container */ function symfonyFromConfig($config) { $file = TEMP_DIR . '/container.php'; $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); $container->addCompilerPass(new \Symfony\Component\DependencyInjection\Compiler\AutowirePass()); $loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($container, new \Symfony\Component\Config\FileLocator(TEMP_DIR)); $loader->load(asfile('config.yml', $config)); $container->compile(); $dumper = new \Symfony\Component\DependencyInjection\Dumper\PhpDumper($container); file_put_contents($file, $dumper->dump()); require_once $file; return new ProjectServiceContainer(); }
<?php require_once __DIR__ . '/../../vendor/autoload.php'; $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); $fileLocator = new \Symfony\Component\Config\FileLocator(__DIR__ . '/config'); $loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($container, $fileLocator); $loader->load('services.yml'); $container->setParameter('config_path', __DIR__ . '/config'); while (true) { $builder = $container->get('amqp.builder.factory'); $connection = $builder->connection('live'); $connection->disconnect(); unset($connection); }