2016-07-08 14:58:30 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Resume.PHP.
|
|
|
|
*
|
|
|
|
* (copyleft) R. Eric Wheeler <sikofitt@gmail.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2016-07-11 14:56:40 -07:00
|
|
|
use Knp\Provider\ConsoleServiceProvider;
|
|
|
|
use Sikofitt\Config\ConfigServiceProvider;
|
|
|
|
use Sikofitt\Json\JsonServiceProvider;
|
|
|
|
use Silex\Provider\{
|
|
|
|
AssetServiceProvider,
|
|
|
|
CsrfServiceProvider,
|
|
|
|
FormServiceProvider,
|
|
|
|
HttpFragmentServiceProvider,
|
|
|
|
HttpKernelServiceProvider,
|
|
|
|
LocaleServiceProvider,
|
|
|
|
MonologServiceProvider,
|
|
|
|
RoutingServiceProvider,
|
|
|
|
ServiceControllerServiceProvider,
|
|
|
|
SessionServiceProvider,
|
|
|
|
TranslationServiceProvider,
|
|
|
|
TwigServiceProvider,
|
|
|
|
ValidatorServiceProvider,
|
|
|
|
VarDumperServiceProvider,
|
|
|
|
WebProfilerServiceProvider
|
|
|
|
};
|
2016-07-15 10:02:18 -07:00
|
|
|
use Symfony\Component\Debug\ErrorHandler;
|
|
|
|
use Symfony\Component\Debug\ExceptionHandler;
|
2016-07-11 14:56:40 -07:00
|
|
|
use Symfony\Bridge\Monolog\Logger;
|
|
|
|
use WhoopsPimple\WhoopsServiceProvider;
|
2016-07-10 18:45:50 -07:00
|
|
|
|
2016-07-11 14:56:40 -07:00
|
|
|
$app->register(new ConfigServiceProvider(), [
|
2016-07-13 14:48:30 -07:00
|
|
|
'config.path' => $app->getConfDirectory() . '/config.yml',
|
2016-07-08 14:58:30 -07:00
|
|
|
]);
|
|
|
|
|
2016-07-15 10:02:18 -07:00
|
|
|
ErrorHandler::register();
|
|
|
|
ExceptionHandler::register(false);
|
|
|
|
|
2016-07-08 14:58:30 -07:00
|
|
|
$app->setDebug();
|
|
|
|
|
2016-07-13 14:29:34 -07:00
|
|
|
|
2016-07-11 14:56:40 -07:00
|
|
|
$app
|
|
|
|
->register(new TwigServiceProvider(), [
|
2016-07-13 14:29:34 -07:00
|
|
|
'twig.path' => $app->getAppDirectory() . '/themes/' . $app->config('app.theme'),
|
2016-07-11 14:56:40 -07:00
|
|
|
])
|
|
|
|
->register(new JsonServiceProvider())
|
|
|
|
->register(new AssetServiceProvider())
|
|
|
|
->register(new MonologServiceProvider())
|
|
|
|
->register(new SessionServiceProvider())
|
|
|
|
->register(new HttpKernelServiceProvider())
|
|
|
|
->register(new FormServiceProvider())
|
|
|
|
->register(new LocaleServiceProvider())
|
|
|
|
->register(new TranslationServiceProvider())
|
|
|
|
->register(new ValidatorServiceProvider())
|
|
|
|
->register(new CsrfServiceProvider())
|
|
|
|
->register(new MonologServiceProvider(), [
|
2016-07-13 15:07:27 -07:00
|
|
|
//'monolog.logfile' => sprintf('%s/%s.log', $app->getLogDirectory(), $app['env']),
|
2016-07-11 14:56:40 -07:00
|
|
|
'monolog.name' => 'Resume.PHP',
|
2016-07-13 15:07:27 -07:00
|
|
|
'monolog.logfile' => 'php://stderr',
|
2016-07-11 14:56:40 -07:00
|
|
|
'monolog.level' => $app->getDebug() ? Logger::DEBUG : Logger::INFO,
|
2016-07-13 15:02:03 -07:00
|
|
|
'monolog.handler' => new \Monolog\Handler\StreamHandler('php://stderr'),
|
2016-07-11 14:56:40 -07:00
|
|
|
])
|
2016-07-15 10:02:18 -07:00
|
|
|
->register(new \Silex\Provider\SwiftmailerServiceProvider())
|
|
|
|
->register(new ConsoleServiceProvider(), [
|
|
|
|
'console.name' => 'Resume.PHP',
|
|
|
|
'console.version' => '0.0.1',
|
|
|
|
'console.project_directory' => $app->getAppDirectory(),
|
|
|
|
]);
|
2016-07-13 14:29:34 -07:00
|
|
|
|
2016-07-15 10:02:18 -07:00
|
|
|
if(false === getenv('SPARKPOST_API_KEY') && null !== $app->config('app.smtp_host')) {
|
|
|
|
$app['swiftmailer.options'] = [
|
|
|
|
'host' => $app->config('app.smtp_host'),
|
|
|
|
'port' => $app->config('app.smtp_post'),
|
|
|
|
'username' => $app->config('app.smtp_user'),
|
|
|
|
'password' => $app->config('app.smtp_password'),
|
|
|
|
];
|
|
|
|
$app->log('Setting up local email.');
|
|
|
|
} elseif (false !== getenv('SPARKPOST_API_KEY')) {
|
2016-07-13 14:29:34 -07:00
|
|
|
$app['swiftmailer.options'] = [
|
|
|
|
'host' => getenv('SPARKPOST_SMTP_HOST'),
|
|
|
|
'port' => getenv('SPARKPOST_SMTP_PORT'),
|
|
|
|
'username' => getenv('SPARKPOST_SMTP_USERNAME'),
|
|
|
|
'password' => getenv('SPARKPOST_SMTP_PASSWORD'),
|
|
|
|
'encryption' => 'tls',
|
|
|
|
];
|
2016-07-15 10:02:18 -07:00
|
|
|
$app->log('Setting up sparkpost email.');
|
|
|
|
} else {
|
|
|
|
$app['swiftmailer.transport'] = new Swift_SendmailTransport();
|
2016-07-13 14:29:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$app->register(new RoutingServiceProvider())
|
2016-07-11 14:56:40 -07:00
|
|
|
->register(new ServiceControllerServiceProvider())
|
|
|
|
->register(new HttpFragmentServiceProvider());
|
|
|
|
|
2016-07-08 14:58:30 -07:00
|
|
|
if ($app['debug'] || 0 === strcasecmp($app['env'], 'dev')) {
|
2016-07-11 14:56:40 -07:00
|
|
|
$app->register(new WebProfilerServiceProvider(), [
|
2016-07-08 14:58:30 -07:00
|
|
|
'profiler.cache_dir' => $app->getDataDirectory() . '/cache/profiler',
|
2016-07-11 14:56:40 -07:00
|
|
|
])
|
|
|
|
->register(new WhoopsServiceProvider())
|
2016-07-15 10:02:18 -07:00
|
|
|
->register(new VarDumperServiceProvider());
|
2016-07-11 14:56:40 -07:00
|
|
|
}
|
|
|
|
if (null === $app->config('app.schema')) {
|
|
|
|
$app->config('app.schema', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
|
2016-07-08 14:58:30 -07:00
|
|
|
}
|