<?php

namespace Silktide\Syringe;

use Silktide\Syringe\Loader\JsonLoader;
use Silktide\Syringe\Loader\YamlLoader;

/**
 * Create Containers from DI configuration
 * 
 * Uses static methods in order to be accessible from 
 */
class Syringe
{

    /**
     * @var ContainerBuilder
     */
    protected static $builder;

    /**
     * Initialise the DI container builder
     * 
     * @param string $appDir - the root directory of the application
     * @param array $configFiles - the syringe config files to load into the container
     */
    public static function init($appDir, array $configFiles)
    {
        $resolver = new ReferenceResolver();
        $loaders = [
            new JsonLoader(),
            new YamlLoader()
        ];

        $configPaths = [
            $appDir
        ];

        self::$builder = new ContainerBuilder($resolver, $configPaths);

        foreach ($loaders as $loader) {
            self::$builder->addLoader($loader);
        }
        self::$builder->setApplicationRootDirectory($appDir);
        
        self::$builder->addConfigFiles($configFiles);
    }

    /**
     * Build a new DI container
     * 
     * @return \Pimple\Container
     */
    public static function createContainer()
    {
        return self::$builder->createContainer();
    }

}
<?php

namespace Silktide\Syringe;

use Silktide\Syringe\Loader\JsonLoader;
use Silktide\Syringe\Loader\YamlLoader;

/**
 * Create Containers from DI configuration
 * 
 * Uses static methods in order to be accessible from 
 */
class Syringe
{

    protected static $loaders;
    
    protected static $appDir;
    
    protected static $configFiles;

    /**
     * Initialise the DI container builder
     * 
     * @param string $appDir - the root directory of the application
     * @param array $configFiles - the syringe config files to load into the container
     */
    public static function init($appDir, array $configFiles)
    {
        self::$loaders = [
            new JsonLoader(),
            new YamlLoader()
        ];
        
        self::$appDir = $appDir;
        self::$configFiles = $configFiles;
    }

    /**
     * Build a new DI container
     * 
     * @return \Pimple\Container
     */
    public static function createContainer()
    {
        $resolver = new ReferenceResolver();
        
        $builder = new ContainerBuilder($resolver, [self::$appDir]);

        foreach (self::$loaders as $loader) {
            $builder->addLoader($loader);
        }
        $builder->setApplicationRootDirectory(self::$appDir);

        $builder->addConfigFiles(self::$configFiles);

        return $builder->createContainer();
    }

}
Rebuild the entire ContainerBuilder when getting a new container - Getting more than one container from the same ContainerBuilder caused some services to be linked and private services didn't match the registered private names
Rebuild the entire ContainerBuilder when getting a new container
 - Getting more than one container from the same ContainerBuilder caused some services to be linked and private services didn't match the registered private names
