resume/web/index.php

45 lines
1.5 KiB
PHP
Raw Normal View History

2016-07-02 10:58:30 -07:00
<?php
2016-07-02 17:10:55 -07:00
use Silex\Provider\TwigServiceProvider;
use WhoopsSilex\WhoopsServiceProvider;
2016-07-03 09:05:44 -07:00
use Sikofitt\Config\YamlFileLoader;
use Symfony\Component\Config;
2016-07-02 10:58:30 -07:00
require_once __DIR__.'/../vendor/autoload.php';
2016-07-02 17:10:55 -07:00
define('APP_ROOT', __DIR__ . '/../');
2016-07-03 09:05:44 -07:00
define('SCHEMA_URL', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
2016-07-02 10:58:30 -07:00
$app = new Silex\Application();
2016-07-02 17:10:55 -07:00
$app->register(new TwigServiceProvider(), [
'twig.path' => __DIR__.'/../views',
]);
2016-07-03 09:05:44 -07:00
$app['config'] = function($app) {
$configFromFiles = \Noodlehaus\Config::load(APP_ROOT . 'config');
$defaultOptions = new \Sikofitt\Config($configFromFiles->all());
return $defaultOptions;
};
2016-07-02 17:10:55 -07:00
$app->register(new WhoopsServiceProvider());
2016-07-03 09:05:44 -07:00
$app->register(new \Silex\Provider\AssetServiceProvider());
$app->register(new \Silex\Provider\MonologServiceProvider());
$app->register(new \Silex\Provider\VarDumperServiceProvider());
$app->register(new \Silex\Provider\HttpKernelServiceProvider());
2016-07-02 17:10:55 -07:00
$app['json.decoder'] = function($app) {
return new Webmozart\Json\JsonDecoder();
};
$app['json.encoder'] = function($app) {
return new Webmozart\Json\JsonEncoder();
};
$app['json.validator'] = function($app) {
return new Webmozart\Json\JsonValidator();
};
$app->get('/', function() use($app) {
2016-07-03 09:05:44 -07:00
$decoded = $app['json.decoder']->decodeFile(APP_ROOT . 'resume.json', APP_ROOT . 'resume.schema.json');
dump($app['config']->get('app.debug'));
return $app['twig']->render('base.html.twig', ['resume' => $decoded]);
2016-07-02 10:58:30 -07:00
});
$app->run();