fbpx
blank

We’re happy to announce that we have deployed the latest release candidate version of PHP 8 on all our servers. PHP 8 is expected to facilitate developers to write cleaner code with better quality that gets executed faster. Since release candidates are not suitable for live sites, we invite you to try it out on a staging copy of your site or on projects that are not live yet. We’ll give away 6 Months of our Deluxe shared hosting to 10 of the early adopters who share their opinion about PHP 8 with us. 

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;
}

The list of new features keeps going and we suggest this article as a good reference point for PHP developers:

https://stitcher.io/blog/new-in-php-8
https://stitcher.io/blog/php-jit
https://wiki.php.net/rfc/nullsafe_operator

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 – For Managed WordPress Clients, Go to your Control Panel, Select PHP Settings, Then change the version – For Shared hosting, cPanel Control Panel –> MultiPHP Manager to change your PHP Version. With PHP8 still being a Release Candidate, we strongly advise that you do not enable it for your live sites, but run tests with it on our staging environment (Staging environments can be created on any plan, If you have trouble doing this, please feel free to reach out to our support team for information on how to do this.), or create copies of your sites in your accounts if you do not have the staging functionality. 

Currently unavailable in PHP 8

The following extensions and modules are not currently available for PHP 8:

Incompatible with PHP 8

The following software currently does not work with PHP 8. This list is not comprehensive.

  • DSO — cPanel & WHM does not support the DSO handler with PHP 8.
  • The XMLRPC extensions — This extension moved to PECL.
  • The JSON extension — This functionality is included in PHP 8 by default.

Tell us what you think and win 6 Months of free hosting

We tried to give you the big picture of what the new PHP8 is all about. Now we would like to hear what you actually think about it, once you get the chance to try it out. What do you like and what do you dislike? How does it work on your website? Do you see any performance improvements? We are looking to explore how our more experienced users take advantage of this early release candidate before it becomes official.

To encourage you to share your tests and opinions with us, We will be giving away 6 months of our Deluxe Shared Hosting service (Normally $9.99 a month) to 10 random users who share their thoughts on PHP8 by December 31, 2020 in a comment under this post, or on Facebook or Twitter, tagging @TheCoreHosting1 and using the hashtag #PHP8 in their post.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x