Improved configuration

This commit is contained in:
Alejandro Celaya 2016-04-10 09:52:44 +02:00
parent c6997bda64
commit 998a926c35
4 changed files with 15 additions and 23 deletions

12
config/app.php Normal file
View file

@ -0,0 +1,12 @@
<?php
use Zend\Expressive\Application;
use Zend\ServiceManager\ServiceManager;
require __DIR__ . '/../vendor/autoload.php';
// Build container
$config = require __DIR__ . '/config.php';
$container = new ServiceManager($config['services']);
$container->setService('config', $config);
return $container->get(Application::class);

View file

@ -1,5 +1,4 @@
<?php
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\Glob;

View file

@ -1,16 +0,0 @@
<?php
use Zend\ServiceManager\Config;
use Zend\ServiceManager\ServiceManager;
// Load configuration
$config = require __DIR__ . '/config.php';
// Build container
$container = new ServiceManager();
(new Config($config['services']))->configureServiceManager($container);
// Inject config
$container->setService('config', $config);
return $container;

View file

@ -1,11 +1,8 @@
<?php
use Zend\Expressive\Application;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
/** @var \Interop\Container\ContainerInterface $container */
$container = require 'config/container.php';
/** @var \Zend\Expressive\Application $app */
$app = $container->get(\Zend\Expressive\Application::class);
/** @var Application $app */
$app = include 'config/app.php';
$app->run();