8000 Factorize code · symfony/recipes@eb279c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb279c0

Browse files
committed
Factorize code
1 parent b819c9a commit eb279c0

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
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);
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
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-
}
5+
$kernel = require __DIR__.'/../src/bootstrap.php';
146

157
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
168
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
179
}
18-
1910
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
2011
Request::setTrustedHosts(explode(',', $trustedHosts));
2112
}
22-
23-
$kernel = new Kernel($env, $debug);
2413
$request = Request::createFromGlobals();
14+
2515
$response = $kernel->handle($request);
2616
$response->send();
2717
$kernel->terminate($request, $response);

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)
0