* * 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\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; use Symfony\Bridge\Monolog\Logger; use WhoopsPimple\WhoopsServiceProvider; $app->register(new ConfigServiceProvider(), [ 'config.path' => $app->getConfDirectory() . '/config.yml', ]); ErrorHandler::register(); ExceptionHandler::register(false); $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.logfile' => 'php://stderr', 'monolog.level' => $app->getDebug() ? Logger::DEBUG : Logger::INFO, 'monolog.handler' => new \Monolog\Handler\StreamHandler('php://stderr'), ]) ->register(new \Silex\Provider\SwiftmailerServiceProvider()) ->register(new ConsoleServiceProvider(), [ 'console.name' => 'Resume.PHP', 'console.version' => '0.0.1', 'console.project_directory' => $app->getAppDirectory(), ]); 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')) { $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', ]; $app->log('Setting up sparkpost email.'); } else { $app['swiftmailer.transport'] = new Swift_SendmailTransport(); } $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()); } if (null === $app->config('app.schema')) { $app->config('app.schema', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json'); }