Skip to content

Commit b74e2bc

Browse files
committed
Add PHP 8.0
1 parent b4ec4f9 commit b74e2bc

24 files changed

+100559
-65
lines changed

docker/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ RUN \
2525
php7.2-fpm php7.2-xml php7.2-intl php7.2-mysql php7.2-mbstring php7.2-curl php7.2-zip php7.2-apcu \
2626
php7.3-fpm php7.3-xml php7.3-intl php7.3-mysql php7.3-mbstring php7.3-curl php7.3-zip php7.3-apcu \
2727
php7.4-fpm php7.4-xml php7.4-intl php7.4-mysql php7.4-mbstring php7.4-curl php7.4-zip php7.4-apcu \
28+
php8.0-fpm php8.0-xml php8.0-intl php8.0-mysql php8.0-mbstring php8.0-curl php8.0-zip php8.0-apcu \
2829
# Fix update-alternatives warning
2930
&& touch /usr/share/man/man1/php5.6.40.gz \
3031
&& touch /usr/share/man/man1/php7.0.33.gz \
@@ -39,13 +40,15 @@ RUN \
3940
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/bin/update-alternatives --set php /usr/bin/php7.2" >> /etc/sudoers.d/phpbenchmarks \
4041
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/bin/update-alternatives --set php /usr/bin/php7.3" >> /etc/sudoers.d/phpbenchmarks \
4142
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/bin/update-alternatives --set php /usr/bin/php7.4" >> /etc/sudoers.d/phpbenchmarks \
43+
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/bin/update-alternatives --set php /usr/bin/php8.0" >> /etc/sudoers.d/phpbenchmarks \
4244
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service nginx reload" >> /etc/sudoers.d/phpbenchmarks \
4345
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php5.6-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4446
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php7.0-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4547
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php7.1-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4648
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php7.2-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4749
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php7.3-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4850
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php7.4-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
51+
&& echo "phpbenchmarks ALL=(ALL) NOPASSWD: /usr/sbin/service php8.0-fpm restart" >> /etc/sudoers.d/phpbenchmarks \
4952
&& chmod -R 777 \
5053
/etc/nginx/sites-enabled \
5154
/var/log/nginx \
@@ -55,6 +58,7 @@ RUN \
5558
/etc/php/7.2/fpm/conf.d \
5659
/etc/php/7.3/fpm/conf.d \
5760
/etc/php/7.4/fpm/conf.d \
61+
/etc/php/8.0/fpm/conf.d \
5862
# Create phpbenchmarks user, we assume final host user id will be 1000 (should be it 99% of the time)
5963
&& useradd -ms /bin/bash --uid 1000 phpbenchmarks \
6064
&& usermod -a -G www-data phpbenchmarks \
@@ -72,6 +76,8 @@ RUN \
7276
&& sed -i 's/group = www-data/group = phpbenchmarks/g' /etc/php/7.3/fpm/pool.d/www.conf \
7377
&& sed -i 's/user = www-data/user = phpbenchmarks/g' /etc/php/7.4/fpm/pool.d/www.conf \
7478
&& sed -i 's/group = www-data/group = phpbenchmarks/g' /etc/php/7.4/fpm/pool.d/www.conf \
79+
&& sed -i 's/user = www-data/user = phpbenchmarks/g' /etc/php/8.0/fpm/pool.d/www.conf \
80+
&& sed -i 's/group = www-data/group = phpbenchmarks/g' /etc/php/8.0/fpm/pool.d/www.conf \
7581
# Define PHP 7.4 as default
7682
&& /usr/bin/update-alternatives --set php /usr/bin/php7.4 \
7783
# Remove nginx default page

public/phpinfo.php

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,40 @@
5252
</tbody>
5353
</table>
5454

55-
<table>
56-
<tbody>
57-
<tr class="h h_phpbenchmarks">
58-
<td colspan="3">
59-
<h1 class="p">opcache_get_status()</h1>
60-
</td>
61-
</tr>
62-
<?php $currentStatusKey = null; ?>
63-
<?php foreach (['memory_usage', 'interned_strings_usage', 'opcache_statistics'] as $statusKey) { ?>
64-
<?php foreach ($opcacheStatus[$statusKey] as $key => $value) { ?>
65-
<tr class="<?php if ($currentStatusKey === $statusKey) echo 'foo' ?>">
66-
<?php if ($currentStatusKey !== $statusKey) { ?>
67-
<td class="e" rowspan="<?= count($opcacheStatus[$statusKey]) ?>>"><?= $statusKey ?></td>
68-
<?php } ?>
69-
<td class="v"><?= $key ?></td>
70-
<td class="v">
71-
<?php
72-
if (in_array($key, ['start_time', 'last_restart_time'])) {
73-
echo $value === 0 ? $value : (new \DateTime())->setTimestamp($value)->format('Y-m-d H:i:s');
74-
} elseif (is_numeric($value)) {
75-
echo number_format($value);
76-
} else {
77-
echo $value;
78-
}
79-
?>
80-
</td>
81-
</tr>
82-
<?php $currentStatusKey = $statusKey ?>
55+
<?php if (is_array($opcacheStatus)) { ?>
56+
<table>
57+
<tbody>
58+
<tr class="h h_phpbenchmarks">
59+
<td colspan="3">
60+
<h1 class="p">opcache_get_status()</h1>
61+
</td>
62+
</tr>
63+
<?php $currentStatusKey = null; ?>
64+
<?php foreach (['memory_usage', 'interned_strings_usage', 'opcache_statistics'] as $statusKey) { ?>
65+
<?php foreach ($opcacheStatus[$statusKey] as $key => $value) { ?>
66+
<tr class="<?php if ($currentStatusKey === $statusKey) echo 'foo' ?>">
67+
<?php if ($currentStatusKey !== $statusKey) { ?>
68+
<td class="e" rowspan="<?= count($opcacheStatus[$statusKey]) ?>>"><?= $statusKey ?></td>
69+
<?php } ?>
70+
<td class="v"><?= $key ?></td>
71+
<td class="v">
72+
<?php
73+
if (in_array($key, ['start_time', 'last_restart_time'])) {
74+
echo $value === 0 ? $value : (new \DateTime())->setTimestamp($value)->format('Y-m-d H:i:s');
75+
} elseif (is_numeric($value)) {
76+
echo number_format($value);
77+
} else {
78+
echo $value;
79+
}
80+
?>
81+
</td>
82+
</tr>
83+
<?php $currentStatusKey = $statusKey ?>
84+
<?php } ?>
8385
<?php } ?>
84-
<?php } ?>
85-
</tbody>
86-
</table>
86+
</tbody>
87+
</table>
88+
<?php } ?>
8789

8890
<?php $preload = ini_get('opcache.preload'); ?>
8991
<?php if (is_string($preload) === true) { ?>
@@ -111,33 +113,37 @@
111113
</tbody>
112114
</table>
113115

114-
<table>
115-
<tbody>
116-
<tr class="h h_phpbenchmarks">
117-
<td colspan="2">
118-
<h1 class="p">opcache_get_status()['preload_statistics']</h1>
119-
</td>
120-
</tr>
121-
<tr>
122-
<td class="e">memory_consumption</td>
123-
<td class="v"><?= number_format($opcacheStatus['preload_statistics']['memory_consumption']) ?></td>
124-
</tr>
125-
<tr>
126-
<?php $countPreloadedScripts = count($opcacheStatus['preload_statistics']['scripts']) ?>
127-
<td class="e" rowspan="<?= max(1, $countPreloadedScripts) ?>">scripts [<?= $countPreloadedScripts ?>]</td>
128-
<td class="v">
129-
<?= $countPreloadedScripts > 0 ? App\Utils\Path::rmPrefix($opcacheStatus['preload_statistics']['scripts'][0]) : null ?>
130-
</td>
131-
</tr>
132-
<?php foreach ($opcacheStatus['preload_statistics']['scripts'] as $index => $script) { ?>
133-
<?php if ($index > 0) { ?>
134-
<tr>
135-
<td class="v"><?= App\Utils\Path::rmPrefix($script) ?></td>
136-
</tr>
116+
<?php if (is_array($opcacheStatus)) { ?>
117+
<table>
118+
<tbody>
119+
<tr class="h h_phpbenchmarks">
120+
<td colspan="2">
121+
<h1 class="p">opcache_get_status()['preload_statistics']</h1>
122+
</td>
123+
</tr>
124+
<tr>
125+
<td class="e">memory_consumption</td>
126+
<td class="v">
127+
<?= number_format($opcacheStatus['preload_statistics']['memory_consumption']) ?>
128+
</td>
129+
</tr>
130+
<tr>
131+
<?php $countPreloadedScripts = count($opcacheStatus['preload_statistics']['scripts'] ) ?>
132+
<td class="e" rowspan="<?= max(1, $countPreloadedScripts) ?>">scripts [<?= $countPreloadedScripts ?>]</td>
133+
<td class="v">
134+
<?= $countPreloadedScripts > 0 ? App\Utils\Path::rmPrefix($opcacheStatus['preload_statistics']['scripts'][0]) : null ?>
135+
</td>
136+
</tr>
137+
<?php foreach ($opcacheStatus['preload_statistics']['scripts'] as $index => $script) { ?>
138+
<?php if ($index > 0) { ?>
139+
<tr>
140+
<td class="v"><?= App\Utils\Path::rmPrefix($script) ?></td>
141+
</tr>
142+
<?php } ?>
137143
<?php } ?>
138-
<?php } ?>
139-
</tbody>
140-
</table>
144+
</tbody>
145+
</table>
146+
<?php } ?>
141147
<?php } ?>
142148
</div>
143149

src/PhpVersion/PhpVersion.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public static function getAll(): PhpVersionArray
1515
new static(7, 1),
1616
new static(7, 2),
1717
new static(7, 3),
18-
new static(7, 4)
18+
new static(7, 4),
19+
new static(8, 0)
1920
]
2021
);
2122
}
@@ -54,6 +55,8 @@ public function toString(): string
5455

5556
public function isPreloadAvailable(): bool
5657
{
57-
return $this->getMajor() >= 7 && $this->getMinor() >= 4;
58+
return
59+
($this->getMajor() === 7 && $this->getMinor() >= 4)
60+
|| $this->getMajor() >= 8;
5861
}
5962
}

symfony.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
"symfony/dependency-injection": {
100100
"version": "v4.4.1"
101101
},
102+
"symfony/deprecation-contracts": {
103+
"version": "v2.1.3"
104+
},
102105
"symfony/dotenv": {
103106
"version": "v4.4.1"
104107
},
@@ -156,18 +159,12 @@
156159
"symfony/http-kernel": {
157160
"version": "v4.4.1"
158161
},
159-
"symfony/mime": {
160-
"version": "v4.4.1"
161-
},
162162
"symfony/options-resolver": {
163163
"version": "v4.4.2"
164164
},
165165
"symfony/polyfill-ctype": {
166166
"version": "v1.13.1"
167167
},
168-
"symfony/polyfill-intl-idn": {
169-
"version": "v1.13.1"
170-
},
171168
"symfony/polyfill-mbstring": {
172169
"version": "v1.13.1"
173170
},
@@ -177,6 +174,9 @@
177174
"symfony/polyfill-php73": {
178175
"version": "v1.13.1"
179176
},
177+
"symfony/polyfill-php80": {
178+
"version": "v1.18.1"
179+
},
180180
"symfony/process": {
181181
"version": "v4.4.1"
182182
},
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# add commands to initialize benchmark: clear cache and logs, warm up cache etc
6+
composer install --no-dev --classmap-authoritative --ansi
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; ----------------------------------------------------------------------------------------------------------------------
2+
; This file will be added to PHP ini files loaded before benchmarking.
3+
; Configure what you need here.
4+
;
5+
; /!\ Do NOT configure opcache.enable: it will be configured automatically.
6+
; /!\ Do NOT configure opcache.preload and opcache.preload_user: it will be configured automatically. /!\
7+
; ----------------------------------------------------------------------------------------------------------------------
8+
9+
; Examples of configuration you could change for your needs.
10+
11+
; The maximum number of keys (scripts) in the OPcache hash table.
12+
; Only numbers between 200 and 1000000 are allowed.
13+
;opcache.max_accelerated_files=10000
14+
15+
; If disabled, all PHPDoc comments are dropped from the code to reduce the
16+
; size of the optimized code.
17+
;opcache.save_comments=1
18+
19+
; A bitmask, where each bit enables or disables the appropriate OPcache
20+
; passes
21+
;opcache.optimization_level=0x7FFFBFFF
22+
23+
; Allows exclusion of large files from being cached. By default all files
24+
; are cached.
25+
;opcache.max_file_size=0
26+
27+
; Enables or disables opcode caching in shared memory.
28+
;opcache.file_cache_only=0
29+
30+
; The OPcache shared memory storage size.
31+
;opcache.memory_consumption=128
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
// You can configure PHP preload in this file.

0 commit comments

Comments
 (0)