コード例 #1
0
 public function setUp()
 {
     $cacheFactory = function () {
         $cacheDriver = new \Stash\Driver\FileSystem();
         return new \Stash\Pool($cacheDriver);
     };
     $injector = new Auryn\Injector();
     $injector->delegate('Pool', $cacheFactory);
     $injector->define('APG\\Fleet\\Fleet', [':airline' => 'AFA', ':path' => 'tests/test_files']);
     $this->fleet = $injector->make('APG\\Fleet\\Fleet');
     $this->aircraftCollection = new \APG\Fleet\Collections\AircraftCollection();
 }
コード例 #2
0
ファイル: Bootstrap.php プロジェクト: acidvertigo/vela
$ssl = $url['port'] == '443' ? true : false;
/**
 * Start dic container
 */
$dic = new \Auryn\Injector();
// Share object instances
$services = [$config, $db, $mail(), $request(), $response(), $time(), $url];
foreach ($services as $service) {
    $dic->share($service);
}
//check if user is a robot
$robots = (require_once __DIR__ . '/Config/' . ENVIRONMENT . '/Robots.php');
/**
 * Start user object
 */
$user = $dic->make('\\Vela\\Core\\User');
$userAgent = $user->getUserAgent();
$userIp = $user->getUserIp();
if (!$user->isRobot($userAgent, $robots)) {
    /**
     * Initialize session object
     */
    $session_factory = new \Aura\Session\SessionFactory();
    $session = $session_factory->newInstance($_COOKIE);
    // set session name
    $session_id = $config->get('session.id');
    if ($session->getName() !== $session_id) {
        $session->setName($session_id);
    }
    // set cookie parameters
    $session->setCookieParams([$config->get('cookie.lifetime'), $config->get('cookie.path'), 'domain' => $url['host'], 'secure' => $ssl, $config->get('cookie.httponly')]);
コード例 #3
0
<?php

$t1 = microtime(true);
$injector = new Auryn\Injector();
for ($i = 0; $i < 10000; $i++) {
    $a = $injector->make('A');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
コード例 #4
0
<?php

$injector = new Auryn\Injector();
//Trigger all autoloaders
$a = $injector->make('J');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $injector->make('J');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
コード例 #5
0
ファイル: load.php プロジェクト: equinoxmatt/fleet
<?php

require_once "vendor/autoload.php";
$cacheFactory = function () {
    $cacheDriver = new \Stash\Driver\FileSystem();
    return new \Stash\Pool($cacheDriver);
};
$injector = new Auryn\Injector();
$injector->delegate('Pool', $cacheFactory);
$injector->define('APG\\Fleet\\Fleet', [':airline' => 'AFA', ':path' => 'downloads/fleet/standard/']);
$fleet = $injector->make('APG\\Fleet\\Fleet');
コード例 #6
0
ファイル: bootstrap.php プロジェクト: exts/app
/**
 * -------------------------------
 * | DEPENDENCY INJECTOR
 * -------------------------------
 */
$injector = new Auryn\Injector();
/**
 * -------------------------------
 * | SETUP CONFIG
 * -------------------------------
 */
$injector->share(YamlLoader::class);
$injector->define(YamlLoader::class, [':directory' => PATH['CONFIG']]);
$injector->define(Config::class, ['loader' => YamlLoader::class]);
/** @var Config $config */
$config = $injector->make(Config::class);
/**
 * -------------------------------
 * | SETUP TWIG
 * -------------------------------
 */
/** @var \G4MR\Configs\Item $twig_options */
$twig_options = $config->getItem('twig');
$injector->share(Twig_Loader_Filesystem::class);
$injector->define(Twig_Loader_Filesystem::class, [':paths' => PATH['TEMPLATE']]);
$injector->share(Twig_Environment::class);
$injector->define(Twig_Environment::class, ['loader' => Twig_Loader_Filesystem::class, ':options' => ['autoescape' => $twig_options->get('autoescape', false), 'strict_variables' => $twig_options->get('strict_variables', false)]]);
/**
 * -------------------------------
 * | SETUP RENDERER & VIEW
 * -------------------------------
コード例 #7
0
<?php

$injector = new Auryn\Injector();
$injector->share('A');
//Trigger all autoloaders
$a = $injector->make('B');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $injector->make('B');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
コード例 #8
0
<?php

// di
$injector = new \Auryn\Injector();
$signer = new Kunststube\CSRFP\SignatureGenerator(getenv('CSRF_SECRET'));
$injector->share($signer);
$blade = new duncan3dc\Laravel\BladeInstance(getenv('VIEWS_DIRECTORY'), getenv('CACHE_DIRECTORY'));
$injector->share($blade);
$injector->make('Acme\\Http\\Request');
$injector->make('Acme\\Http\\Response');
$injector->make('Acme\\Http\\Session');
$injector->share('Acme\\Http\\Request');
$injector->share('Acme\\Http\\Response');
$injector->share('Acme\\Http\\Session');
$injector->define('Acme\\Auth\\LoggedIn', ['session' => 'Acme\\Http\\Session']);
$injector->make('Acme\\Auth\\LoggedIn');
return $injector;