Esempio n. 1
0
 public function setUp()
 {
     $containerBuilder = new \DI\ContainerBuilder();
     $containerBuilder->addDefinitions([iConfig::class => \DI\object(Config::class)->constructor(require __DIR__ . '/../config/main.php')]);
     $this->_container = $containerBuilder->build();
     $this->init();
 }
Esempio n. 2
0
 /**
  *
  */
 public static function init()
 {
     $builder = new \DI\ContainerBuilder();
     $builder->setDefinitionCache(new ApcCache());
     $builder->writeProxiesToFile(true, 'tmp/proxies');
     self::$container = $builder->build();
     self::$container->set('routeCollection', new RouteCollection());
 }
Esempio n. 3
0
 /**
  * @param array $definitions
  *
  * @return \DI\Container
  */
 public static function build($definitions)
 {
     $builder = new \DI\ContainerBuilder();
     $builder->useAutowiring(false);
     $builder->useAnnotations(false);
     $builder->addDefinitions($definitions);
     return $builder->build();
 }
 /**
  * PHP-DIのコンテナを初期化する。
  */
 protected function initializeContainer()
 {
     parent::initializeContainer();
     $builder = new \DI\ContainerBuilder();
     $builder->wrapContainer($this->getContainer());
     $builder->useAnnotations(true);
     $this->getContainer()->setFallbackContainer($builder->build());
 }
Esempio n. 5
0
 public function __construct()
 {
     $builder = new \DI\ContainerBuilder();
     $container = $builder->build();
     //Register Notification Implementation
     $container->set('Services_NotifyInterface', \DI\object('Services_TwitterNotify'));
     $this->_container = $container;
     return $container;
 }
Esempio n. 6
0
 public function __construct($api_key, $api_secret)
 {
     $builder = new \DI\ContainerBuilder();
     $di = $builder->build();
     $di->set('api_key', $api_key);
     $di->set('api_secret', $api_secret);
     $di->set('request', new Request());
     self::setDi($di);
     $this->initProperties();
 }
Esempio n. 7
0
 protected function setUp()
 {
     $builder = new \DI\ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->addDefinitions([Twig_Environment::class => function () {
         $loader = new Twig_Loader_Filesystem(realpath(__DIR__ . '/../../templates'));
         return new Twig_Environment($loader, array('cache' => 'test/template_cache', 'auto_reload' => true));
     }]);
     $this->router = new ControllerRouter($builder->build());
 }
Esempio n. 8
0
 public static function run($worker_id, $data)
 {
     $jobs = Config::getJobs();
     $job =& $jobs[$worker_id];
     if ($job === null) {
         var_dump($worker_id);
         return false;
     }
     $builder = new \DI\ContainerBuilder();
     // $builder->setDefinitionCache(new Doctrine\Common\Cache\RedisCache());
     $builder->writeProxiesToFile(true, 'tmp/proxies');
     // $builder->useAutowiring(false);
     $builder->useAnnotations(false);
     $builder->addDefinitions('diconfig.php');
     $container = $builder->build();
     // $dependencies = &$job['dependencies'];
     //
     // if ($dependencies !== null) {
     //     $dependencies_classes = explode(',',$dependencies);
     //     foreach($dependencies_classes  as $class) {
     //         $depend_jober = new $class($params);
     //         $params = $depend_jober->run();
     //         if ($params === false) {
     //             return false;
     //         }
     //     }
     // }
     $retries =& $job['retries'];
     $job_params =& $job['params'];
     $class =& $job['class'];
     $exec_count = 0;
     do {
         $result = $container->get($class)->run($data, $job_params);
         $exec_count++;
     } while ($result === false && $exec_count < $retries);
     if ($result === false) {
         $notify = Config::getNotify();
         switch ($notify['dispatch_mode']) {
             case 1:
                 break;
             case 2:
                 break;
         }
     }
 }
Esempio n. 9
0
<?php

require __DIR__ . '/../vendor/autoload.php';
date_default_timezone_set('UTC');
session_start();
$builder = new DI\ContainerBuilder();
$builder->addDefinitions('../config/di.php');
$builder->addDefinitions(['api.base_url' => 'http://localhost:8080', 'oauth2.client_id' => 'GPa5aZntQiqREY1E9ZWV', 'oauth2.client_secret' => '735fa055695bd683b7bfc0de4e6b4fc2ce2c7f46', 'oauth2.redirect_uri' => 'http://localhost:8081/authorize.php', 'oauth2.base_url' => 'http://localhost:8080']);
$container = $builder->build();
Esempio n. 10
0
$builder->useAnnotations(true);
if (\Fraym\Core::ENV_STAGING === ENV || \Fraym\Core::ENV_PRODUCTION === ENV) {
    error_reporting(-1);
    ini_set("display_errors", 0);
    $builder->writeProxiesToFile(true, CACHE_DI_PATH);
    define('GLOBAL_CACHING_ENABLED', true);
    $apcEnabled = (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
} else {
    error_reporting(-1);
    ini_set("display_errors", 1);
    define('GLOBAL_CACHING_ENABLED', false);
    $apcEnabled = false;
}
define('APC_ENABLED', $apcEnabled);
if (defined('IMAGE_PROCESSOR') && IMAGE_PROCESSOR === 'Imagick') {
    $builder->addDefinitions(['Imagine' => DI\object('Imagine\\Imagick\\Imagine')]);
} elseif (defined('IMAGE_PROCESSOR') && IMAGE_PROCESSOR === 'Gmagick') {
    $builder->addDefinitions(['Imagine' => DI\object('Imagine\\Gmagick\\Imagine')]);
} else {
    $builder->addDefinitions(['Imagine' => DI\object('Imagine\\Gd\\Imagine')]);
}
$builder->addDefinitions(['db.options' => array('driver' => DB_DRIVER, 'user' => DB_USER, 'password' => DB_PASS, 'host' => DB_HOST, 'dbname' => DB_NAME, 'charset' => DB_CHARSET)]);
if (APC_ENABLED) {
    $cache = new Doctrine\Common\Cache\ApcuCache();
} else {
    $cache = new Doctrine\Common\Cache\ArrayCache();
}
$cache->setNamespace('Fraym_instance_' . FRAYM_INSTANCE);
$builder->setDefinitionCache($cache);
$diContainer = $builder->build();
Esempio n. 11
0
File: index.php Progetto: vtk13/cc
<?php

require_once '../vendor/autoload.php';
session_start();
function h($value)
{
    return htmlspecialchars($value);
}
$builder = new \DI\ContainerBuilder();
$builder->useAnnotations(true);
$builder->addDefinitions('../config/config.php');
$router = new \Vtk13\Mvc\Handlers\ControllerRouter($builder->build(), 'Vtk13\\Cc\\Controller\\', '/', 'index');
$response = $router->handle(\Vtk13\Mvc\Http\Request::createFromGlobals());
if (!headers_sent()) {
    header($response->getStatusLine());
    foreach ($response->getHeaders() as $name => $value) {
        header("{$name}: {$value}");
    }
    echo $response->getBody();
}
Esempio n. 12
0
<?php

use Curve\AppKernel;
require_once __DIR__ . '/vendor/autoload.php';
$containerBuilder = new \DI\ContainerBuilder();
$containerBuilder->addDefinitions(__DIR__ . '/src/Curve/AppContainer.php');
$container = $containerBuilder->build();
/** @var AppKernel $app */
$app = $container->get("Curve\\AppKernel");
$input = json_decode(file_get_contents($argv[1]), true);
echo $app->start($input)->getTotal() . "\n";
Esempio n. 13
0
<?php

use thewulf7\friendloc\components\Application;
use thewulf7\friendloc\components\config\{iConfig, Config};
use function DI\object;
use function DI\get;
ini_set('display_errors', 0);
require '../../vendor/autoload.php';
$containerBuilder = new \DI\ContainerBuilder();
$containerBuilder->addDefinitions([iConfig::class => object(Config::class)->constructor(require '../config/main.php'), Application::class => object(Application::class)]);
/** @var Application $app */
$app = $containerBuilder->build()->get('\\thewulf7\\friendloc\\components\\Application');
$app->setDevMode(true)->run();