Skip to content

Commit bcedbd7

Browse files
steevanbphpbenchmarks
authored andcommitted
Symfony 4.3.0 REST API benchmark
1 parent 7338daa commit bcedbd7

File tree

11 files changed

+1055
-530
lines changed

11 files changed

+1055
-530
lines changed

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

Lines changed: 311 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 311 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 311 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
You will find lot of benchmarks for PHP frameworks and template engines on [phpbenchmarks.com](http://www.phpbenchmarks.com).
1010

11-
Benchmarks results are available for Apache Bench and Siege, and PHP 5.6 to 7.3.
11+
Benchmarks results are available from PHP 5.6 to latest version.
1212

1313
Our benchmarking protocol is available on [benchmarking protocol page](http://www.phpbenchmarks.com/en/documentation/benchmarking-protocol).
1414

bin/console

Lines changed: 26 additions & 2 deletions
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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
"ext-ctype": "*",
88
"ext-iconv": "*",
99
"phpbenchmarks/symfony-common": "4.3.3",
10-
"symfony/console": "4.3.0-BETA2",
11-
"symfony/dotenv": "4.3.0-BETA2",
10+
"symfony/console": "4.3.0",
11+
"symfony/dotenv": "4.3.0",
1212
"symfony/flex": "^1.1",
13-
"symfony/framework-bundle": "4.3.0-BETA2",
13+
"symfony/framework-bundle": "4.3.0",
1414
"symfony/serializer-pack": "^1.0",
15-
"symfony/translation": "4.3.0-BETA2",
16-
"symfony/yaml": "4.3.0-BETA2"
15+
"symfony/translation": "4.3.0",
16+
"symfony/yaml": "4.3.0"
1717
},
18-
"minimum-stability": "beta",
1918
"config": {
2019
"preferred-install": {
2120
"*": "dist"
@@ -41,7 +40,7 @@
4140
"extra": {
4241
"symfony": {
4342
"allow-contrib": false,
44-
"require": "4.3.0-BETA2"
43+
"require": "4.3.0"
4544
}
4645
}
4746
}

config/bootstrap.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
use Symfony\Component\Dotenv\Dotenv;
44

5-
require dirname(__DIR__) . '/vendor/autoload.php';
5+
require dirname(__DIR__).'/vendor/autoload.php';
66

7-
$env = @include dirname(__DIR__) . '/.env.local.php';
8-
if (is_array($env)) {
9-
$_SERVER += $env;
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')) {
1010
$_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.');
1113
} else {
12-
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
14+
// load all the .env files
15+
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
1316
}
1417

15-
$_SERVER['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
16-
$_ENV['APP_ENV'] = $_SERVER['APP_ENV'];
17-
18+
$_SERVER += $_ENV;
19+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
1820
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
19-
$_SERVER['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN)
20-
? '1'
21-
: '0';
22-
$_ENV['APP_DEBUG'] = $_SERVER['APP_DEBUG'];
21+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

src/.bootstrap.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Controller/.gitignore

Whitespace-only changes.

src/Kernel.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@ class Kernel extends BaseKernel
1313
{
1414
use MicroKernelTrait;
1515

16-
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
16+
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
1717

18-
public function getCacheDir()
19-
{
20-
return $this->getProjectDir().'/var/cache/'.$this->environment;
21-
}
22-
23-
public function getLogDir()
24-
{
25-
return $this->getProjectDir().'/var/log';
26-
}
27-
28-
public function registerBundles()
18+
public function registerBundles(): iterable
2919
{
3020
$contents = require $this->getProjectDir().'/config/bundles.php';
3121
foreach ($contents as $class => $envs) {
@@ -40,7 +30,7 @@ public function getProjectDir(): string
4030
return \dirname(__DIR__);
4131
}
4232

43-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
33+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
4434
{
4535
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
4636
$container->setParameter('container.dumper.inline_class_loader', true);
@@ -52,12 +42,12 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
5242
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
5343
}
5444

55-
protected function configureRoutes(RouteCollectionBuilder $routes)
45+
protected function configureRoutes(RouteCollectionBuilder $routes): void
5646
{
5747
$confDir = $this->getProjectDir().'/config';
5848

59-
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
6049
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
50+
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
6151
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
6252
}
6353
}

0 commit comments

Comments
 (0)