Last active
August 27, 2018 13:47
-
-
Save miedzwin/f7ec0e0d51fd88b147037ef189c7960a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Load environment variables from file and init them | |
* | |
* @throws \Exception | |
*/ | |
private function initEnvironmentVars() | |
{ | |
$containerBuilder = new ContainerBuilder(); | |
$fileLocator = new FileLocator(__DIR__ . '/../../'); | |
$yamlFileLoader = new YamlFileLoader($containerBuilder, $fileLocator); | |
try { | |
$yamlFileLoader->load('.env.yml'); | |
} catch (InvalidArgumentException $e) { | |
die('Invalid yaml file structure.'); | |
} catch (\Exception $e) { | |
die('.env.yml file not found. Application cannot start.'); | |
} | |
$containerBuilder->compile(); | |
$parameterBag = $containerBuilder->getParameterBag(); | |
foreach ($parameterBag->all() as $key => $value) { | |
putenv("$key=$value"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$loader = require __DIR__ . '/../vendor/autoload.php'; | |
// ILFW entry point | |
use App\Container; | |
use App\Router; | |
use Symfony\Component\HttpFoundation\Request; | |
session_start(); | |
$container = new Container(); | |
$container->init('app'); | |
$container->setParameter('routes', (new Router())->getRouteCollection()); | |
$request = Request::createFromGlobals(); | |
$response = $container->get('framework')->handle($request); | |
$response->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment