70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
|
|
use Knp\Snappy\Pdf;
|
|
use Sikofitt\Json\ResumeBuilder;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Webmozart\Json\FileNotFoundException;
|
|
use Webmozart\Json\ValidationFailedException;
|
|
use Silex\Provider\TwigServiceProvider;
|
|
use Symfony\Component\Config;
|
|
use Webmozart\Json\DecodingFailedException;
|
|
use WhoopsSilex\WhoopsServiceProvider;
|
|
|
|
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(),
|
|
]);
|
|
|
|
$app->register (new TwigServiceProvider(), [
|
|
'twig.path' => APP_ROOT . 'app/views',
|
|
]);
|
|
$app['conf'] = function ($app) {
|
|
|
|
};
|
|
|
|
$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());
|
|
$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');
|
|
}
|
|
|
|
return new Response($message, $code);
|
|
});
|
|
$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) {
|
|
|
|
//$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');
|
|
return $app['twig']->render('resume.html.twig');
|
|
});
|
|
|
|
$app->run ();
|