/** * @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; }
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); }
<?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; // }
// 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'); }); // Bind an existing "authentication" class instance to the container $auth = new Acme\Authentication(); $container->instance('auth', $auth); /* |-------------------------------------------------------------------------- | Routes |-------------------------------------------------------------------------- */ $app = new \Slim\Slim(); $app->get('/', function () use($container) { // Create new Acme\Template instance $template = $container->make('template'); // Render template echo $template->render('home'); }); $app->get('/send-email', function () use($container) { // Create new Acme\Mailer instance $mailer = $container->make('mailer');
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(); }); $app->hook('slim.after.router', function ($container) use($container) { $container->make('session')->save(); }); return $app;