Archived
1
0
Fork 0

Create a Bootstrap class and move bootstrap code from public/index.php

This commit is contained in:
Henrik Hautakoski 2018-06-18 17:42:30 +02:00
parent b3254e1f6c
commit e85d935734
4 changed files with 61 additions and 26 deletions

33
app/library/Bootstrap.php Normal file
View file

@ -0,0 +1,33 @@
<?php
namespace Httpcb;
use Phalcon\Di\FactoryDefault as DiDefault;
use Phalcon\Di\Injectable;
use Phalcon\DiInterface;
use Phalcon\Mvc\Application;
class Bootstrap extends Injectable
{
public function __construct(DiInterface $di = null)
{
if ($di === null) {
$di = new DiDefault();
}
$this->setDI($di);
}
public function run()
{
$app = new Application($this->getDI());
// Force autoloader if registered.
// Should be needed by almost all other services.
$di = $this->getDI();
if ($di->has('loader')) {
$di->get('loader');
}
return $app->handle()->getContent();
}
}