We are excited to announce that Kyakabi
Data now supports PHP 8. As always we
are among the first companies to provide
the new PHP on their hosting platform.
PHP 8 is expected to facilitate
developers to write cleaner code with
better quality that gets executed
faster.
What are the PHP 8 improvements and
features
Faster code execution
The latest PHP version brings a lot of
new things but the one we are obsessed
with is JIT (just in time compiler). It
is the first time that PHP version has a
compiler – JIT – that caches a version
of your already interpreted code and
generates a machine code as an output
(machine code is on with 0’s and 1’s
only). The “just in time” compiler
promises speed improvements for complex
tasks and algorithms and opens new
opportunities for the PHP language to
broaden its reach and
applications.
Some of you may wonder how JIT relates to
the Opcache, which brought significant
performance gains to many websites? The
main job of the Opcache is to cut the
processes of tokenization, parsing, and
compiling of Opcodes, which then get
processed by the Zend engine. The role
of JIT is to save on the execution of
the Opcodes by the Zend engine, so it
joins forces and intervenes to spare
resources where the Opcache cannot help.
It’s worth mentioning a few downsides we
have noticed so far:
Running PHP 8 with JIT might make it
harder for you to troubleshoot code
errors because it may be harder to
locate which piece of your code in
this interpreted version is actually
at fault.
If you are running a WordPress site
you may not be able to note
significant performance improvements
thanks to JIT. The WP developers are
still working on making WP
compatible with PHP
8 and are now calling
for testers, meaning you won’t be
really able to test PHP8 on your WP
site right away. Also, because of
the way WP interacts with MySQL, a
lot of the waiting time does not
come from the PHP compilation, but
from the MySQL response time, which
cannot be solved with the help of
the JIT compiler.
Code with higher quality
One of the major differences that you
will notice is that many of the warnings
and notices that weren’t catchable are
now exceptions or errors, which can be
caught and logged. It is possible that
due to this change, a lot of problems
that remained hidden with the previous
PHP versions will now surface. This is a
great improvement, as it will allow
developers to spot potential issues
easier. However, have in mind that
it may be a good idea to
set display_errors=Off if
you decide to use PHP 8 on a live site
to not show such errors to your site
visitors.
Cleaner, shorter code
Some of the new elements, such as the
nullsafe operator, greatly improve the
readability of the code, making it
shorter and neater. Instead of
nesting several “if’s” you can use the
“null” operator to write all those in
just 1 line of code.
The “type” trend
For several versions now, PHP has been
trying to define the arguments that each
method could adopt and become more of a
typed language. In this latest release,
there is a feature called “union types”
which allows you to define 2 value types
for each function, which is a natural
continuation of that trend. As the
example below shows, the function can
return an integer or a float:
public function getNumber():
int|float { return
$this->number; }
How to take advantage of PHP 8 on our
platform?
All our clients can change the PHP
version of their sites from their
control panel – Site Tools > Dev
section, or cPanel > PHP versions.
With PHP8 still being a new, we strongly
advise that you do not enable it for
your live sites, but run tests with it
on our staging environment, or create
copies of your sites in your accounts if
you do not have the staging
functionality.
At the moment, we have deployed PHP 8
without the following modules: mcrypt,
geoip, ioncube.
Ddumba works as the business
development manager and leads
Kyakabi Group long term vision. He
is responsible to drive market share
growth in designated territories
which kyakabi's brands operate.