Skip to content

Commit 8602353

Browse files
steevanbphpbenchmarks
authored and
phpbenchmarks
committed
Symfony 4.3.0 Hello world benchmark
1 parent d8b6752 commit 8602353

File tree

9 files changed

+978
-490
lines changed

9 files changed

+978
-490
lines changed

.phpbenchmarks/composer/composer.lock.php7.1

+297-153
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpbenchmarks/composer/composer.lock.php7.2

+297-153
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpbenchmarks/composer/composer.lock.php7.3

+297-153
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/console

+26-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,39 @@
44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
66
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\Debug\Debug;
8+
9+
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
10+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
11+
}
712

813
set_time_limit(0);
914

1015
require dirname(__DIR__).'/vendor/autoload.php';
1116

17+
if (!class_exists(Application::class)) {
18+
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19+
}
20+
1221
$input = new ArgvInput();
22+
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
23+
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24+
}
25+
26+
if ($input->hasParameterOption('--no-debug', true)) {
27+
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
28+
}
29+
30+
require dirname(__DIR__).'/config/bootstrap.php';
31+
32+
if ($_SERVER['APP_DEBUG']) {
33+
umask(0000);
1334

14-
require dirname(__DIR__).'/src/.bootstrap.php';
35+
if (class_exists(Debug::class)) {
36+
Debug::enable();
37+
}
38+
}
1539

16-
$kernel = new Kernel('prod', false);
40+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
1741
$application = new Application($kernel);
1842
$application->run($input);

composer.json

+18-17
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
"php": "^7.1.3",
77
"ext-ctype": "*",
88
"ext-iconv": "*",
9-
"symfony/console": "4.3.0-BETA2",
9+
"phpbenchmarks/symfony-common": "4.1.1",
10+
"symfony/cache": "4.3.0",
11+
"symfony/config": "4.3.0",
12+
"symfony/console": "4.3.0",
13+
"symfony/debug": "4.3.0",
14+
"symfony/dependency-injection": "4.3.0",
15+
"symfony/dotenv": "4.3.0",
16+
"symfony/event-dispatcher": "4.3.0",
17+
"symfony/filesystem": "4.3.0",
18+
"symfony/finder": "4.3.0",
1019
"symfony/flex": "^1.1",
11-
"symfony/framework-bundle": "4.3.0-BETA2",
12-
"symfony/yaml": "4.3.0-BETA2",
13-
"symfony/routing": "4.3.0-BETA2",
14-
"symfony/http-foundation": "4.3.0-BETA2",
15-
"symfony/event-dispatcher": "4.3.0-BETA2",
16-
"symfony/debug": "4.3.0-BETA2",
17-
"symfony/http-kernel": "4.3.0-BETA2",
18-
"symfony/finder": "4.3.0-BETA2",
19-
"symfony/filesystem": "4.3.0-BETA2",
20-
"symfony/dependency-injection": "4.3.0-BETA2",
21-
"symfony/config": "4.3.0-BETA2",
22-
"symfony/var-exporter": "4.3.0-BETA2",
23-
"symfony/cache": "4.3.0-BETA2",
24-
"symfony/mime": "4.3.0-BETA2",
25-
"phpbenchmarks/symfony-common": "4.1.1"
20+
"symfony/framework-bundle": "4.3.0",
21+
"symfony/http-foundation": "4.3.0",
22+
"symfony/http-kernel": "4.3.0",
23+
"symfony/mime": "4.3.0",
24+
"symfony/routing": "4.3.0",
25+
"symfony/var-exporter": "4.3.0",
26+
"symfony/yaml": "4.3.0"
2627
},
2728
"config": {
2829
"preferred-install": {
@@ -49,7 +50,7 @@
4950
"extra": {
5051
"symfony": {
5152
"allow-contrib": false,
52-
"require": "4.3.0-BETA2"
53+
"require": "4.3.0"
5354
}
5455
}
5556
}

config/bootstrap.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
// Load cached env vars if the .env.local.php file exists
8+
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9+
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
10+
$_ENV += $env;
11+
} elseif (!class_exists(Dotenv::class)) {
12+
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
13+
} else {
14+
// load all the .env files
15+
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
16+
}
17+
18+
$_SERVER += $_ENV;
19+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
20+
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
21+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

public/index.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
<?php
22

33
use App\Kernel;
4+
use Symfony\Component\Debug\Debug;
45
use Symfony\Component\HttpFoundation\Request;
56

6-
require dirname(__DIR__).'/src/.bootstrap.php';
7+
require dirname(__DIR__).'/config/bootstrap.php';
8+
9+
if ($_SERVER['APP_DEBUG']) {
10+
umask(0000);
11+
12+
Debug::enable();
13+
}
714

815
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
916
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
1017
}
1118

1219
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
13-
Request::setTrustedHosts(explode(',', $trustedHosts));
20+
Request::setTrustedHosts([$trustedHosts]);
1421
}
1522

16-
$kernel = new Kernel('prod', false);
23+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
1724
$request = Request::createFromGlobals();
1825
$response = $kernel->handle($request);
1926
$response->send();

src/.bootstrap.php

-6
This file was deleted.

symfony.lock

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"symfony/cache": {
1818
"version": "4.2-dev"
1919
},
20+
"symfony/cache-contracts": {
21+
"version": "v1.1.1"
22+
},
2023
"symfony/config": {
2124
"version": "4.2-dev"
2225
},
@@ -29,18 +32,21 @@
2932
"ref": ""
3033
}
3134
},
32-
"symfony/contracts": {
33-
"version": "1.0-dev"
34-
},
3535
"symfony/debug": {
3636
"version": "4.2-dev"
3737
},
3838
"symfony/dependency-injection": {
3939
"version": "4.2-dev"
4040
},
41+
"symfony/dotenv": {
42+
"version": "v4.3.0"
43+
},
4144
"symfony/event-dispatcher": {
4245
"version": "4.2-dev"
4346
},
47+
"symfony/event-dispatcher-contracts": {
48+
"version": "v1.1.1"
49+
},
4450
"symfony/filesystem": {
4551
"version": "4.2-dev"
4652
},
@@ -98,6 +104,9 @@
98104
"ref": ""
99105
}
100106
},
107+
"symfony/service-contracts": {
108+
"version": "v1.1.2"
109+
},
101110
"symfony/var-exporter": {
102111
"version": "4.2-dev"
103112
},

0 commit comments

Comments
 (0)