Early last December, php8.2.0 was released. I did not install it at the first available. I like to wait for the first wave of bugs to be fixed.

Now it is time to upgrade my Web Server’s php engine. Before upgrading, it is PHP8.1.18. The server is powered by Ubuntu 22.04LTS. 1GB Ram, 1Core Intel Processor. on Vultr.com.

I am using Ondrej sury PPA as the source of existing PHP8.1. Since I am already adding this PPA to my system. I just entered the following command to install PHP8.2.

sudo apt install php8.2 php8.2-fpm php8.2-cli php8.2-common php8.2-mbstring php8.2-gd php8.2-intl php8.2-xml php8.2-mysql php8.2-zip php8.2-curl php8.2-bcmath

phpinfo of PHP8.2.6

Tests on PHP8.1.18

phpinfo of PHP8.1.18

Bench Test Result.

simple             0.004
simplecall         0.002
simpleucall        0.002
simpleudcall       0.002
mandel             0.016
mandel2            0.023
ackermann(7)       0.010
ary(50000)         0.003
ary2(50000)        0.003
ary3(2000)         0.020
fibo(30)           0.029
hash1(50000)       0.004
hash2(500)         0.005
heapsort(20000)    0.012
matrix(20)         0.011
nestedloop(12)     0.012
sieve(30)          0.006
strcat(200000)     0.002
------------------------
Total              0.167

Micro-Bench Test Result

empty_loop         0.012
func()             0.012    0.000
undef_func()       0.012    0.000
int_func()         0.012    0.000
$x = self::$x      0.060    0.048
self::$x = 0       0.056    0.044
isset(self::$x)    0.058    0.046
empty(self::$x)    0.060    0.048
$x = Foo::$x       0.036    0.024
Foo::$x = 0        0.029    0.017
isset(Foo::$x)     0.029    0.017
empty(Foo::$x)     0.037    0.025
self::f()          0.012    0.000
Foo::f()           0.013    0.001
$x = $this->x      0.026    0.014
$this->x = 0       0.026    0.014
$this->x += 2      0.042    0.030
++$this->x         0.038    0.026
--$this->x         0.043    0.031
$this->x++         0.039    0.027
$this->x--         0.039    0.027
isset($this->x)    0.034    0.022
empty($this->x)    0.041    0.029
$this->f()         0.051    0.038
$x = Foo::TEST     0.044    0.032
new Foo()          0.124    0.112
$x = TEST          0.024    0.012
$x = $_GET         0.049    0.037
$x = $GLOBALS['v'] 0.057    0.045
$x = $hash['v']    0.012    0.000
$x = $str[0]       0.012    0.000
$x = $a ?: null    0.012    0.000
$x = $f ?: tmp     0.012    0.000
$x = $f ? $f : $a  0.012    0.000
$x = $f ? $f : tmp 0.012    0.000
------------------------
Total              1.187

Bubble Test Result

0.043275833129883

Tests on PHP 8.2.6

Bench Test Result

simple             0.004
simplecall         0.002
simpleucall        0.002
simpleudcall       0.002
mandel             0.015
mandel2            0.024
ackermann(7)       0.009
ary(50000)         0.003
ary2(50000)        0.003
ary3(2000)         0.020
fibo(30)           0.031
hash1(50000)       0.005
hash2(500)         0.005
heapsort(20000)    0.012
matrix(20)         0.011
nestedloop(12)     0.012
sieve(30)          0.006
strcat(200000)     0.003
------------------------
Total              0.168

Micro-Bench Test Result

empty_loop         0.012
func()             0.012    0.000
undef_func()       0.012    0.000
int_func()         0.012    0.000
$x = self::$x      0.062    0.050
self::$x = 0       0.055    0.043
isset(self::$x)    0.056    0.044
empty(self::$x)    0.055    0.043
$x = Foo::$x       0.031    0.019
Foo::$x = 0        0.024    0.012
isset(Foo::$x)     0.026    0.014
empty(Foo::$x)     0.029    0.017
self::f()          0.012    0.000
Foo::f()           0.012    0.000
$x = $this->x      0.024    0.012
$this->x = 0       0.026    0.014
$this->x += 2      0.043    0.031
++$this->x         0.034    0.022
--$this->x         0.034    0.022
$this->x++         0.036    0.024
$this->x--         0.034    0.022
isset($this->x)    0.032    0.020
empty($this->x)    0.036    0.024
$this->f()         0.050    0.038
$x = Foo::TEST     0.042    0.030
new Foo()          0.118    0.106
$x = TEST          0.023    0.011
$x = $_GET         0.045    0.033
$x = $GLOBALS['v'] 0.037    0.025
$x = $hash['v']    0.012    0.000
$x = $str[0]       0.012    0.000
$x = $a ?: null    0.012    0.000
$x = $f ?: tmp     0.012    0.000
$x = $f ? $f : $a  0.012    0.000
$x = $f ? $f : tmp 0.012    0.000
------------------------
Total              1.094

Bubble Test Result

0.040456056594849

There are some improvements.

 

For now, I keep both PHP8.1.18 and PHP8.2.6 on the server. Change the website’s nginx config files, one by one. Test every site to make sure they are good on PHP8.2.

I will take down php8.1 support when I am comfortable with all the websites on my server.

Reference:

What’s New on PHP 8.2?

  • Readonly classes
  • Disjunctive Normal Form (DNF) Types
  • Allow null, false, and true as stand-alone types
  • New “Random” extension
  • Constants in traits
  • Deprecate dynamic properties
  • New Classes, Interfaces, and Functions
  • Deprecations and backward compatibility breaks

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *