Skip to content

Commit

Permalink
Add new config file to environment
Browse files Browse the repository at this point in the history
refactor in index.php to work in developer and production just changing parameters in environment.php
  • Loading branch information
lenonleite committed Apr 12, 2023
1 parent 6d9ac34 commit 62a7094
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/config/environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'debug' => false,
'env' => 'prod', //dev
'dev_ip_whitelist' => [
'127.0.0.1',
'::1',
'172.17.0.1',
],
];
14 changes: 12 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
date_default_timezone_set('UTC');

require_once 'autoload.php';
$config = include 'app/config/environment.php';

use Mautic\CoreBundle\ErrorHandler\ErrorHandler;
use Mautic\Middleware\MiddlewareBuilder;
use Symfony\Component\HttpFoundation\Request;

ErrorHandler::register('prod');
//ErrorHandler::register('prod');
ErrorHandler::register($config['env']);

$kernel = (new MiddlewareBuilder(new AppKernel('prod', false)))->resolve();
if (
'dev' === strtolower($config['env'])
&& extension_loaded('apcu')
&& in_array(@$_SERVER['REMOTE_ADDR'], $config['dev_ip_whitelist'])
) {
@apcu_clear_cache();
}

$kernel = (new MiddlewareBuilder(new AppKernel($config['env'], $config['debug'])))->resolve();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down

0 comments on commit 62a7094

Please # to comment.