public function setupContainer(ComposerParserResult $parserResult)
 {
     $directory = $parserResult->getDirectory();
     $resolver = new ReferenceResolver();
     $loaders = [new JsonLoader(), new YamlLoader()];
     include $directory . "/vendor/autoload.php";
     $builder = new ContainerBuilder($resolver, [$directory]);
     foreach ($loaders as $loader) {
         $builder->addLoader($loader);
     }
     $builder->setApplicationRootDirectory($directory);
     if ($parserResult->usesSyringe()) {
         $builder->addConfigFile($parserResult->getAbsoluteSyringeConfig());
         // This is a hack regarding the somewhat naff way Namespaces can end up working
         $builder->addConfigFiles([$parserResult->getNamespace() => $parserResult->getAbsoluteSyringeConfig()]);
     }
     $additionalConfigs = $this->input->getOption("configs");
     foreach ($additionalConfigs as $config) {
         $builder->addConfigFile(realpath($config));
     }
     $builder->addConfigFiles($parserResult->getConfigList());
     return $builder->createContainer();
 }
Beispiel #2
0
<?php

$appDir = dirname(__DIR__);
include_once $appDir . "/vendor/autoload.php";
use Silktide\Syringe\ReferenceResolver;
use Silktide\Syringe\ContainerBuilder;
use Silktide\Syringe\Loader\JsonLoader;
use Silktide\Syringe\Loader\YamlLoader;
// Config data should be brought in using environment variables
// Updating environment variables is a PITA when doing some quick dev, so if we have an
// env.yml file, dump it into $_SERVER, where syringe will pick it up as if it was an actual environment variable
$environmentFile = __DIR__ . "/../env.yml";
if (file_exists($environmentFile)) {
    $yaml = new \Symfony\Component\Yaml\Yaml();
    $array = $yaml->parse(file_get_contents($environmentFile));
    foreach ($array as $key => $value) {
        $_SERVER[$key] = $value;
    }
}
$resolver = new ReferenceResolver();
$loaders = [new JsonLoader(), new YamlLoader()];
$configPaths = [$appDir . "/app/config", $appDir];
$builder = new ContainerBuilder($resolver, $configPaths);
foreach ($loaders as $loader) {
    $builder->addLoader($loader);
}
$builder->setApplicationRootDirectory($appDir);
$builder->addConfigFiles(["dolondro_hotstuff" => $appDir . "/vendor/dolondro/hotstuff/app/config/services.yml"]);
$builder->addConfigFile("services.yml");