resume/app/providers.php

97 lines
3.1 KiB
PHP
Raw Normal View History

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
};
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
]);
$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-08 14:58:30 -07:00
'monolog.logfile' => sprintf('%s/%s.log', $app->getLogDirectory(), $app['env']),
2016-07-11 14:56:40 -07:00
'monolog.name' => 'Resume.PHP',
'monolog.level' => $app->getDebug() ? Logger::DEBUG : Logger::INFO,
])
2016-07-13 14:29:34 -07:00
->register(new \Silex\Provider\SwiftmailerServiceProvider());
if(false === getenv('SPARKPOST_API_KEY')) {
$app['swiftmailer.transport'] = new Swift_SendmailTransport();
2016-07-13 14:56:16 -07:00
$app->log('We are local');
2016-07-13 14:29:34 -07:00
} 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',
];
2016-07-13 14:56:16 -07:00
$app->log('We are on heroku.');
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())
->register(new VarDumperServiceProvider())
->register(new ConsoleServiceProvider(), [
'console.name' => 'Resume.PHP',
'console.version' => '0.0.1',
'console.project_directory' => $app->getAppDirectory(),
2016-07-08 14:58:30 -07:00
]);
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
}