resume/web/index.php

70 lines
2.2 KiB
PHP
Raw Normal View History

2016-07-02 10:58:30 -07:00
<?php
2016-07-02 17:10:55 -07:00
2016-07-04 18:09:37 -07:00
use Knp\Snappy\Pdf;
2016-07-03 20:54:55 -07:00
use Sikofitt\Json\ResumeBuilder;
2016-07-04 18:09:37 -07:00
use Symfony\Component\HttpFoundation\Response;
2016-07-03 20:54:55 -07:00
use Webmozart\Json\FileNotFoundException;
use Webmozart\Json\ValidationFailedException;
2016-07-02 17:10:55 -07:00
use Silex\Provider\TwigServiceProvider;
2016-07-03 09:05:44 -07:00
use Symfony\Component\Config;
2016-07-03 20:54:55 -07:00
use Webmozart\Json\DecodingFailedException;
use WhoopsSilex\WhoopsServiceProvider;
2016-07-02 10:58:30 -07:00
2016-07-03 20:54:55 -07:00
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../app/App.php';
define ('APP_ROOT', __DIR__ . '/../');
define ('SCHEMA_URL', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
$app = new App();
$app->register(new Sikofitt\Config\ConfigServiceProvider(), [
'config.path' => $app->getConfDirectory(),
]);
2016-07-02 10:58:30 -07:00
2016-07-03 20:54:55 -07:00
$app->register (new TwigServiceProvider(), [
'twig.path' => APP_ROOT . 'app/views',
2016-07-02 17:10:55 -07:00
]);
2016-07-03 20:54:55 -07:00
$app['conf'] = function ($app) {
2016-07-03 09:05:44 -07:00
};
2016-07-03 20:54:55 -07:00
$app->register (new WhoopsServiceProvider());
$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-04 18:09:37 -07:00
$app->error(function (\Exception $e, $code) use($app) {
switch ($code) {
case 404:
$message = $app['twig']->render('error404.html.twig');
break;
default:
$message = $app['twig']->render('error500.html.twig');
}
2016-07-03 20:54:55 -07:00
2016-07-04 18:09:37 -07:00
return new Response($message, $code);
});
2016-07-03 20:54:55 -07:00
$app['json.decoder'] = function ($app) {
2016-07-02 17:10:55 -07:00
return new Webmozart\Json\JsonDecoder();
};
2016-07-03 20:54:55 -07:00
$app['json.encoder'] = function ($app) {
2016-07-02 17:10:55 -07:00
return new Webmozart\Json\JsonEncoder();
};
2016-07-03 20:54:55 -07:00
$app['json.validator'] = function ($app) {
2016-07-02 17:10:55 -07:00
return new Webmozart\Json\JsonValidator();
};
2016-07-03 20:54:55 -07:00
$app->get ('/', function () use ($app) {
2016-07-03 22:17:58 -07:00
2016-07-04 18:09:37 -07:00
//$snappy = new Pdf($app->getRootDirectory() . '/vendor/bin/wkhtmltopdf-amd64');
//$snappy->setTemporaryFolder(sys_get_temp_dir() . '/pdf');
//$snappy->setOption( 'disable-external-links', true);
//$snappy->setOption('toc', false);
//$snappy->setOption('enable-internal-links', false);
//$html = $app['twig']->render('resume.html.twig');
//$snappy->generateFromHtml($html, $app->getRootDirectory() . '/test3.pdf');
2016-07-03 22:17:58 -07:00
return $app['twig']->render('resume.html.twig');
2016-07-02 10:58:30 -07:00
});
2016-07-03 20:54:55 -07:00
$app->run ();