resume/app/providers.php

98 lines
3.2 KiB
PHP

<?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.
*/
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
};
use Symfony\Bridge\Monolog\Logger;
use WhoopsPimple\WhoopsServiceProvider;
$app->register(new ConfigServiceProvider(), [
'config.path' => $app->getConfDirectory() . '/config.yml',
]);
$app->setDebug();
$app
->register(new TwigServiceProvider(), [
'twig.path' => $app->getAppDirectory() . '/themes/' . $app->config('app.theme'),
])
->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(), [
'monolog.logfile' => sprintf('%s/%s.log', $app->getLogDirectory(), $app['env']),
'monolog.name' => 'Resume.PHP',
'monolog.level' => $app->getDebug() ? Logger::DEBUG : Logger::INFO,
'monolog.handler' => new \Monolog\Handler\StreamHandler('php://stderr'),
])
->register(new \Silex\Provider\SwiftmailerServiceProvider());
if(false === getenv('SPARKPOST_API_KEY')) {
$app['swiftmailer.transport'] = new Swift_SendmailTransport();
$app->log('We are local');
} else {
$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',
'auth_mode' => 'plain',
];
$app->log('We are on heroku.');
}
$app->register(new RoutingServiceProvider())
->register(new ServiceControllerServiceProvider())
->register(new HttpFragmentServiceProvider());
if ($app['debug'] || 0 === strcasecmp($app['env'], 'dev')) {
$app->register(new WebProfilerServiceProvider(), [
'profiler.cache_dir' => $app->getDataDirectory() . '/cache/profiler',
])
->register(new WhoopsServiceProvider())
->register(new VarDumperServiceProvider())
->register(new ConsoleServiceProvider(), [
'console.name' => 'Resume.PHP',
'console.version' => '0.0.1',
'console.project_directory' => $app->getAppDirectory(),
]);
}
if (null === $app->config('app.schema')) {
$app->config('app.schema', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
}