Пример #1
0
 /**
  * @return \Illuminate\Container\Container
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function createApplicationContainer()
 {
     $container = new \Illuminate\Container\Container();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $container->instance('config', new \Illuminate\Config\Repository());
     $container->config->set("fluent", $filesystem->getRequire(__DIR__ . '/config/fluent.php'));
     return $container;
 }
Пример #2
0
 protected function setUp()
 {
     $app = new \Illuminate\Container\Container();
     $app['config'] = $this->config = $this->generateMockConfiguration();
     $app['session'] = $this->session = new Store(new MockArraySessionStorage());
     $app['url'] = $this->urlGenerator = new UrlGenerator(new RouteCollection(), Request::create('/edifice', 'GET'));
     $app['html'] = $this->htmlBuilder = new HtmlBuilder($this->urlGenerator);
     $app['form'] = $this->formBuilder = new FormBuilder($this->htmlBuilder, $this->urlGenerator, 'csrfToken');
     $this->edificeServiceProvider = new EdificeServiceProvider($app);
     $this->edificeServiceProvider->register();
     $this->edifice = $app['edifice.form'];
     $app->make('Illuminate\\Container\\Container');
     $app->instance('Illuminate\\Container\\Container', $app);
 }
 /**
  * Get the available container instance.
  *
  * @param  string  $make
  * @return mixed
  */
 function app($make = null)
 {
     if (!is_null($make)) {
         return app()->make($make);
     }
     return Illuminate\Container\Container::getInstance();
 }
Пример #4
0
 function api($make = null, $parameters = [])
 {
     if (is_null($make)) {
         return Illuminate\Container\Container::getInstance();
     }
     return Illuminate\Container\Container::getInstance()->make($make, $parameters);
 }
Пример #5
0
 /**
  * Use or instantiate a Flysystem disk
  *
  * @param string $dir The value from one of the config dirs
  * @return League\Flysystem\Filesystem | League\Flysystem\Cached\CachedAdapter
  */
 public function makeDisk($dir)
 {
     // Check if the dir refers to an IoC binding and return it
     if ($this->app->bound($dir) && ($instance = $this->app->make($dir)) && (is_a($instance, 'League\\Flysystem\\Filesystem') || is_a($instance, 'League\\Flysystem\\Cached\\CachedAdapter'))) {
         return $instance;
     }
     // Instantiate a new Flysystem instance for local dirs
     return new Filesystem(new Adapter($dir));
 }
Пример #6
0
 /**
  * Runs the command!
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int     null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $input->getArgument('application') ?: $this->getConfigValue('application');
     $env = $input->getArgument('environment') ?: $this->getConfigValue('environment');
     if (!$app) {
         return $this->variableNotDefined('application', $output);
     }
     if (!$env) {
         return $this->variableNotDefined('environment', $output);
     }
     if ($input->getOption('interactive')) {
         $this->scriptRunner->enableInteractivity($input, $this->getHelper('question'));
     }
     if ($input->getOption('force')) {
         $this->scriptRunner->continueOnError();
     }
     $this->dispatchEvent('init', $output);
     $branch = exec('echo $(git branch | sed -n -e \'s/^\\* \\(.*\\)/\\1/p\')');
     $commitMsg = exec('echo $(git log --format="%s" -n 1)');
     $output->writeln("<info>APP:</info>" . $app);
     $output->writeln("<info>ENV:</info>" . $env);
     $this->dispatchEvent('before-pack', $output);
     $packer = $this->app->make('Dployer\\Services\\ProjectPacker');
     $packer->setOutput($output);
     $filename = $packer->pack((array) $this->getConfigValue('exclude-paths'), (array) $this->getConfigValue('copy-paths'));
     $this->dispatchEvent('before-deploy', $output);
     $ebsManager = $this->app->make('Dployer\\Services\\EBSVersionManager');
     $ebsManager->init($app, $env, $output);
     $versionLabel = $ebsManager->createVersion($filename, "[{$branch}] {$commitMsg}");
     if ($versionLabel && $ebsManager->deployVersion($versionLabel)) {
         $this->removeZipFile($filename, $output);
         $output->writeln("<info>done</info>");
         $this->dispatchEvent('finish', $output);
         return 0;
     }
     $this->dispatchEvent('finish', $output);
     $output->writeln("<error>failed</error>");
     return 1;
 }
Пример #7
0
use Illuminate\Cache\FileStore;
use Illuminate\Cache\Repository;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Filesystem\Filesystem;
define('FLARUM_START', microtime(true));
require __DIR__ . '/vendor/autoload.php';
// franzliedke/studio currently doesn't autoload files (see issue below), so we
// will need to load them manually if we're using studio.
// https://github.com/franzliedke/studio/issues/29
if (file_exists(__DIR__ . '/core')) {
    require __DIR__ . '/core/src/helpers.php';
    require __DIR__ . '/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
}
$app = new Application(realpath(__DIR__));
$app->instance('path.public', __DIR__ . '/..');
Illuminate\Container\Container::setInstance($app);
if (file_exists($configFile = __DIR__ . '/../config.php')) {
    $app->instance('flarum.config', include $configFile);
}
date_default_timezone_set('UTC');
$app->instance('config', $config = new ConfigRepository(['view' => ['paths' => [realpath(base_path('resources/views'))], 'compiled' => realpath(storage_path() . '/framework/views')], 'mail' => ['driver' => 'mail'], 'cache' => ['default' => 'file', 'stores' => ['file' => ['driver' => 'file', 'path' => storage_path() . '/framework/cache']], 'prefix' => 'flarum'], 'filesystems' => ['default' => 'local', 'cloud' => 's3', 'disks' => ['flarum-avatars' => ['driver' => 'local', 'root' => public_path('assets/avatars')]]]]));
$logger = new Monolog\Logger($app->environment());
$logPath = $app->storagePath() . '/logs/flarum.log';
$handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG);
$handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true));
$logger->pushHandler($handler);
$app->instance('log', $logger);
$app->alias('log', 'Psr\\Log\\LoggerInterface');
$app->singleton('cache', function ($app) {
    $store = new FileStore(new Filesystem(), storage_path('framework/cache'));
    $repository = new Repository($store);
<?php

$container = new \Illuminate\Container\Container();
$container->bind('A', 'A', true);
//Trigger autoloader
$a = $container->make('B');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $b = $container->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);
<?php

$container = new \Illuminate\Container\Container();
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $container->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);
Пример #10
0
<?php

require_once "vendor/autoload.php";
$app = new Illuminate\Container\Container();
$app->bind('FuelInterface', 'Ron95');
$axia = $app->make('Axia');
echo $axia->refuel(100) . PHP_EOL;
$civic = $app->make('CivicTypeR');
echo $civic->refuel(100) . PHP_EOL;
<?php

$container = new \Illuminate\Container\Container();
//trigger autoloader
$j = $container->make('J');
$j2 = $container->make('J');
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $j = $container->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);
Пример #12
0
<?php

/*  This is a basic bootstrap for some of the laravel 5.0 components and entry point to the app itself.
 *  See this article for more infohttp://www.gufran.me/post/laravel-components/ 
 *  */
ini_set('display_errors', 'On');
error_reporting(E_ALL);
require './vendor/autoload.php';
Illuminate\Support\ClassLoader::register();
$path = str_finish(dirname(__FILE__), '/');
// register the autoloader and add directories
$app = new Illuminate\Container\Container();
$app->bind('app', $app);
// this line is different from gufran's post because I'm on laravel 5 and I think his guide was on laravel 4.
require './vendor/illuminate/support/helpers.php';
#require './vendor/illuminate/Foundation/helpers.php';
//
// also bind the base path for some helper methods to use
// Overcome the mental block, you can bind literally anything into the container
$app->bind('path.base', $path);
// Yes, that is an abstract class but you can still access
// static methods
Illuminate\Support\Facades\Facade::setFacadeApplication($app);
// register application instance with container
$app['app'] = $app;
// set environment
$app['env'] = 'production';
$params = parse_ini_file('database.ini');
$baseUrl = $params['baseUrl'];
$basePath = $params['basePath'];
$app['baseUrl'] = $baseUrl;
Пример #13
0
 */
define('__BASE_DIR', dirname(dirname(__DIR__)) . '/');
require __BASE_DIR . 'vendor/autoload.php';
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Start native session to get a session id for the Laravel session store and
// filesystem session handler
session_name('slim-boilerplate');
session_start();
// Environment based configuration
// Allows developers using the getenv('<name>') method to fetch configuration values
if (file_exists(__BASE_DIR . '.env')) {
    Dotenv::load(__BASE_DIR);
}
// IoC container setup
$container = new \Illuminate\Container\Container();
// Application configuration
$config = (include __BASE_DIR . 'app/config/config.php');
$config = new \App\Components\Config\Config($config);
$container->instance('\\App\\Components\\Config\\Config', $config);
$container->alias('\\App\\Components\\Config\\Config', 'config');
// Slim application setup
$container->singleton('Slim\\Slim', function ($container) use($config) {
    $app = new \Slim\Slim(array('debug' => $config->get('app.debug'), 'mode' => $config->get('app.mode'), 'log.enabled' => $config->get('app.logging.enabled'), 'log.level' => $config->get('app.logging.level'), 'log.writer' => new \App\Components\Logging\FileSystemLogWriter(__BASE_DIR . 'app/storage/logs/' . date('ymd') . '.log'), 'templates.path' => __BASE_DIR . 'app/ressources/views', 'view' => new \Slim\Views\Twig()));
    // Twig template engine setup
    $app->view()->parserOptions = array('debug' => $config->get('app.debug'), 'cache' => __BASE_DIR . 'app/storage/cache/views');
    $app->view()->parserExtensions = array(new \Slim\Views\TwigExtension());
    // Laravel session component start and shutdown configuration
    $app->hook('slim.before', function ($container) use($container) {
        $container->make('session')->start();
    });
Пример #14
0
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/config.php';
$app = new Silex\Application(array('debug' => false));
/***
 *
 * Let's configure the database we'll use through Mongovel
 *
 */
$container = new Illuminate\Container\Container();
$container->singleton('mongoveldb', function () {
    return new Mongovel\DB('mongodb://localhost', 'circular');
});
Mongovel\Mongovel::setContainer($container);
/***
 *
 * Let's group controllers on whether they're `public` or `protected`
 *
 */
$public = $app['controllers_factory'];
$protected = $app['controllers_factory'];
/***
 *
 * Auth.
 *
 * Sample output:
 * 	array (
 * 		'id' => '507ed38198dee47b47000001',
Пример #15
0
<?php

require_once "vendor/autoload.php";
$app = new \Illuminate\Container\Container();
$app->when('Axia')->needs('FuelInterface')->give('Ron97');
$axia = $app->make('Axia');
echo $axia->refuel(100) . PHP_EOL;
$civic = $app->make('CivicTypeR');
echo $civic->refuel(100) . PHP_EOL;
Пример #16
0
<?php

require_once "vendor/autoload.php";
$app = new \Illuminate\Container\Container();
$app->bind('FuelInterface', 'Ron95');
// Imagine if out of sudden, you need to calculate GST
// for all the fuels.
$app->afterResolving('FuelInterface', function ($fuel) {
    return $fuel->setPrice($fuel->getPrice() * 1.06);
});
$axia = $app->make('Axia');
echo $axia->refuel(100) . PHP_EOL;
$civic = $app->make('CivicTypeR');
echo $civic->refuel(100) . PHP_EOL;
Пример #17
0
 */
/*
|--------------------------------------------------------------------------
| Bootstrap
|--------------------------------------------------------------------------
*/
// Include project libraries, including a number of mock
// examples of common, real-world services
require_once 'vendor/autoload.php';
require_once 'libraries/Authentication.php';
require_once 'libraries/Controller.php';
require_once 'libraries/Database.php';
require_once 'libraries/Mailer.php';
require_once 'libraries/Template.php';
// Create new IoC Container instance
$container = new Illuminate\Container\Container();
// Bind a "template" class to the container
$container->bind('template', 'Acme\\Template');
// Bind a "mailer" class to the container
// Use a callback to set additional settings
$container->bind('mailer', function ($container) {
    $mailer = new Acme\Mailer();
    $mailer->username = '******';
    $mailer->password = '******';
    $mailer->from = '*****@*****.**';
    return $mailer;
});
// Bind a shared "database" class to the container
// Use a callback to set additional settings
$container->singleton('database', function ($container) {
    return new Acme\Database('username', 'password', 'host', 'database');
Пример #18
0
set_include_path('configs:' . get_include_path());
setlocale(LC_TIME, 'fr_BE');
//Démarrage de la session
session_start();
require "vendor/autoload.php";
//Gestion de la white list des routes
include 'routes.php';
//Inclusion des données de connexion à la db. Ne contient que des constantes qui sont donc globales
include 'db.php';
//Routage
$routeParts = explode('/', $routes['default']);
$a = isset($_REQUEST['a']) ? $_REQUEST['a'] : $routeParts[0];
$e = isset($_REQUEST['e']) ? $_REQUEST['e'] : $routeParts[1];
$route = $a . '/' . $e;
if (!in_array($route, $routes)) {
    die('Vous essayez de joindre une ressource qui n’existe pas');
    //À remplacer par une redirection vers view/error/x
}
//Création du container d’injection de dépendances
$container = new Illuminate\Container\Container();
foreach (include 'bindings.php' as $interface => $concrete) {
    $container->bind($interface, $concrete);
}
//Détermination du controleur à utiliser
$controllerName = '\\Controllers\\' . ucfirst($e);
$controller = $container->make($controllerName);
//Exécution de la fonction correspondant à l’action demandée
$data = call_user_func([$controller, $a]);
//$data contient toujours une clé 'view' et une clé 'data'
//Inclusion de la vue maîtresse
include 'views/layout.php';
Пример #19
0
<?php

$file = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($file)) {
    throw new RuntimeException('Install dependencies to run test suite.');
}
$loader = (require $file);
$loader->add('Parsley\\Examples', __DIR__);
$container = new \Illuminate\Container\Container();
$container->instance('Illuminate\\Container\\Container', $container);
$config = new \Illuminate\Config\Repository(new \Illuminate\Config\FileLoader(new \Illuminate\Filesystem\Filesystem(), __DIR__ . '/app/config'), 'example');
$container->instance('config', $config);
$container->bind('events', 'Illuminate\\Events\\Dispatcher', true);
/** @var Illuminate\Events\Dispatcher $events */
$events = $container['events'];
//$listeners = $events->getListeners('parsley.application: ds2, payload.send');
//$events->listen(
//       '*', function () use ($events) {
//               echo '- Firing ', $events->firing(), PHP_EOL;
//           }
//);
//$events->listen(
//       'parsley.application: *', function () use ($events) {
//               echo ' -- Application fires ', $events->firing(), PHP_EOL;
//           }
//);
//
//$events->listen(
//       'parsley.plugin: *', function () use ($events) {
//               echo '   -- Plugin fires ', $events->firing(), PHP_EOL;
//           }
Пример #20
0
<?php

// Construct the IoC Container
$app = new Illuminate\Container\Container();
// Bind isolator for PHP functions
$app->bind('php', function () {
    return new Icecave\Isolator\Isolator();
}, true);
// Bind the Symfony Console application
$app->bind('console', function () {
    return new Symfony\Component\Console\Application('dployer', '1.2.2');
}, true);
function app()
{
    global $app;
    return $app;
}
<?php

$container = new \Illuminate\Container\Container();
$container->bind('A', 'A', true);
//Trigger autoloader
$a = $container->make('A');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $j = $container->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);