Skip to content

Commit c9cc535

Browse files
committed
Factorize code
1 parent b819c9a commit c9cc535

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

symfony/console/4.2/bin/console

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use App\Kernel;
54
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Debug\Debug;
7-
8-
set_time_limit(0);
9-
10-
[$env, $debug] = require __DIR__.'/../src/bootstrap.php';
115

126
if (!class_exists(Application::class)) {
137
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
148
}
159

16-
if ($debug) {
17-
umask(0000);
18-
19-
if (class_exists(Debug::class)) {
20-
Debug::enable();
21-
}
22-
}
10+
set_time_limit(0);
2311

24-
$kernel = new Kernel($env, $debug);
12+
$kernel = require __DIR__.'/../src/bootstrap.php';
2513
$application = new Application($kernel);
2614
$application->run($input);

symfony/framework-bundle/4.2/public/index.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
<?php
22

3-
use App\Kernel;
4-
use Symfony\Component\Debug\Debug;
53
use Symfony\Component\HttpFoundation\Request;
64

7-
[$env, $debug] = require __DIR__.'/../src/bootstrap.php';
8-
9-
if ($debug) {
10-
umask(0000);
11-
12-
Debug::enable();
13-
}
14-
155
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
166
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
177
}
@@ -20,7 +10,7 @@
2010
Request::setTrustedHosts(explode(',', $trustedHosts));
2111
}
2212

23-
$kernel = new Kernel($env, $debug);
13+
$kernel = require __DIR__.'/../src/bootstrap.php';
2414
$request = Request::createFromGlobals();
2515
$response = $kernel->handle($request);
2616
$response->send();

symfony/framework-bundle/4.2/src/bootstrap.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require __DIR__.'/../vendor/autoload.php';
44

5+
use App\Kernel;
6+
use Symfony\Component\Debug\Debug;
57
use Symfony\Component\Dotenv\Dotenv;
68

79
$envFromEnv = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null;
@@ -14,4 +16,13 @@
1416
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
1517
}
1618

17-
return [$env, (bool) ($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? !$prod)];
19+
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? !$prod);
20+
if ($debug) {
21+
umask(0000);
22+
23+
if (class_exists(Debug::class)) {
24+
Debug::enable();
25+
}
26+
}
27+
28+
return new Kernel($env, $debug);

0 commit comments

Comments
 (0)