Click here to watch the video on YouTube
- Open a terminal window on your host
- Change to the directory that contains the source code for the book:
cd /path/to/repo
- Start the Docker containers running:
- Windows:
init up
- Linux/Mac:
./init.sh up
- Windows:
- For this demo, shell into the PHP 8 container:
- Windows:
init shell 8
- Linux/Mac:
./init.sh shell 8
- Windows:
- Inside the container, change to the directory mapped to the
source code:
cd /repo
- First make sure OpCache is enabled:
cat /etc/php.ini |grep opcache |less
- Have a look at a little program that resets the settings:
less ch10/php8_jit_reset.php
- To start turn off JIT:
php ch10/php8_jit_reset.php off cat /etc/php.ini |grep op_cache
- Have a look at the test code:
less ch10/php8_jit_mandelbrot.php
- Now run it without JIT. From the browser on your host computer, go to this URL: http://localhost:8888/ch10/php8_jit_mandelbrot.php
- Return to the PHP 8 shell and try the outmoded JIT
function setting:
php ch10/php8_jit_reset.php function
- Now run it with JIT in function mode. From the browser on your host computer, go to this URL: http://localhost:8888/ch10/php8_jit_mandelbrot.php
- Now try the new recommended JIT "tracing" setting. From the PHP
shell:
php ch10/php8_jit_reset.php tracing
- Now run it with JIT in function mode. From the browser on your host computer, go to this URL: http://localhost:8888/ch10/php8_jit_mandelbrot.php
- Done!
Notes
-
Starting with PHP version 8.0.1, JIT is disabled if any extension is enabled that uses the internal
zend_execute_ex()
. This includes Xdebug. Accordingly, thephp8_jit_reset.php
program disables the Xdebug extension. If you runphp8_jit_reset.php off
, JIT is disabled, and the Xdebug extension is re-enabled.
For more information see: https://bugs.php.net/bug.php?id=80608. -
The source code associated with the book can be found here: https://github.com/PacktPublishing/PHP-8-Programming-Tips-Tricks-and-Best-Practices