PHP 8 Available on Our Servers (What’s New + Game)

We’re happy to announce that we have deployed the latest release candidate version of PHP 8 on all our servers. 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. 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 awesome PHP elephants 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 – Site Tools > Dev section, or cPanel > PHP versions. 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 is available for GrowBig, GoGeek and Cloud plans), 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.

Tell us what you think and win a PHP elephant

We tried to give you the big picture on 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 stimulate you to share your tests and opinions with us, we have styled and branded the original PHP elephants to celebrate this new release. We’ll give away 10 elephants to 10 random users who share their thoughts on PHP8 by November 26, 2020 in a comment under this post, or on Facebook or Twitter, tagging @SiteGround and using the hashtag #PHP8 in their post.

Hristo Pandjarov

WordPress Initiatives Manager

Enthusiastic about all Open Source applications you can think of, but mostly about WordPress. Add a pinch of love for web design, new technologies, search engine optimisation and you are pretty much there!

Comments ( 26 )

Samuel C carpenter

Oct 09, 2020

It is interesting to see all the complex new developments but I wonder what was wrong with the old Php? It worked and was understood. Now the new Php may work but is not understood therefore requires alot more time to master. How is that an advantage?

Reply

Hristo Pandjarov Siteground Team

Oct 09, 2020

There is nothing wrong with it. Newer versions always improve the performance and readibility of code. That requires some methods to become more strict. It is not harder than previour versions, you just need to keep up-to-date with changes.

Reply

Martin Bean

Oct 19, 2020

Is that not the same with any language advancement? Languages don’t just get released and stay the same for decades; just like natural languages. They grow and evolve.

Reply

Thomas Dutrion

Oct 10, 2020

Hi! Interesting take on PHP 8. While I do like the Jit feature, which will help with calculation and building workers mostly, I would not have it as the main improvement as it's often done. For me, union types are all the rage in PHP 8, and I really can see how it helps specifically in refactoring/doing progressive enhancement on legacy codebases where types where frequently messed up seriously. I really believe (just as it was with nullable types) that these features are also quite dangerous and should never ever be used in a new codebase, but it's so good for legacy codes!!

Reply

Ionut Demeterca

Oct 12, 2020

I for one was really impressed with PHP 7 but hearing about the JIT for PHP 8 and the "union types" made my face glow in the darkness. I look forward to the performance improvements that PHP dev team is doing as I'm obsessed with the performance of my websites.

Reply

André Valverde

Oct 13, 2020

Here at GoMedia.pt we think it's impressive your anticipation to implement # PHP8. Since we are #SiteGround customers, we have seen a constant improvement in the quality of your service, from support to technical specifications, such as the recent migration to #GoogleCloud. Thank you for contributing to our success and the satisfaction of our customers. André Valverde, co-founder at GoMedia.pt

Reply

Jonathan

Oct 14, 2020

Is SiteGround going to include the .zip module with PHP 8.0 when officially released? The .zip module is needed for many back-end theme import/export functions. Also, the missing module is being flagged by WordPress' health check tool. Last, when is SiteGround going to add the .zip module to PHP 7.4.11? Desperately needed. Thank you!

Reply

Hristo Pandjarov Siteground Team

Oct 16, 2020

We've added it to 7.4 and it will be part of 8 too once it reaches stable version.

Reply

Gonzalo

Oct 15, 2020

"Running PHP 8 with JIT might make it harder for you to troubleshoot code errors" Yup, that is true, although it was my impression that we should enable PHP's JIT on production servers and not in development stages (where the bugs/errors should be addressed), so the cases an error occurs in production *and* it can't easily be located in the code will be minimized. Right?

Reply

Hristo Pandjarov Siteground Team

Oct 16, 2020

Personally, I wouldn't enable it unless I need it and have tested it exclusively with my particular script :)

Reply

Jonathan Young

Oct 15, 2020

So many new toys! Union types Might help legacy code work, but only by forgiving its failings. Loose types cause chaos, but at least this ties them down to a defined set and alerts the programmer to their presence. JIT – we will see, it won’t be noticeable for most websites, some people are going to love this, the rest – not so much. The nullsafe operator, again, sort of helps to gloss over the fact that things didn’t work out as planned. You can use this instead of fixing your code now. Named arguments might be good, they might make the code more readable without introducing any dangerous loopholes. The match expression looks interesting, it’s new, so needs to find its place in code that already does what this expression offers. As such, you don’t have to use it, but it will slowly seep in where it makes sense to use it in new code. I like constructor property promotion! Mixed types fall into the same camp as the other novel ways to forgive code that has undefined results. The loose nature of variables is however, a welcome feature making code more flexible, so there will be a lot of this around and so it has its place. The new ‘throw’ is welcome and the change to private method inheritance is good. There are tweaks to error detection and diagnostics. Some changes to interfaces that will need exploring. There are new string functions that I will definitely be happy to see. There is also an end to stupid things like 0==”empty value” is true, well we’ve been coping with this for a long time, I don’t know how I’ll deal with this, the code may change and could make legacy code break, but then this is not the only breaking change, so it will mean lots of testing for any system that migrates.

Reply

Joeri

Oct 20, 2020

An elephant sounds awesome! I haven't tested 8 yet, but this will be the first major release of PHP for which we will be updating more than 75 Wordpress sites for our clients, so exciting times ahead hehe. Is there any roadmap or timeframe for when PHP8 will be implemented in Ultrafast PHP?

Reply

Hristo Pandjarov Siteground Team

Oct 20, 2020

PHP8 is already available in Ultrafast but WordPress is not ready for it. Full support will be introduced in 5.6 but it will take extra time for plugin developers to make the necessary updates so their software works fine with it. So, please, don't enable it on all WordPress sites yet :)

Reply

Fred

Oct 26, 2020

Thanks for the article. I am really looking forward to PHP8. Like so many others, I lost sight of PHP at some point, because especially in larger companies PHP was no longer 'cool' enough and not digital enough and treated like legacy language. A lot of people, especially in the IT security area in big companies, jumped on the bandwagon that PHP itself is just a single security hole and so languages like ASP and Co were preferred which is really sad. Only few people understood the concept of that language and also its development towards PHP7. 99% it is the dev that makes the code insecure not the language. I was often smiled at when I used PHP for small projects in the web and non web area. But unlike many other applications, these have been running stable (and secure) for years. I am curious about the performance because I privately run very large APIs on it, which are more or less compute intensive. So I am looking forward that PHP is hopefully experiencing a renaissance soon. And who knows, maybe even towards strong ML libraries.

Reply

Mark

Oct 29, 2020

Looking forward to all of the improvements on the latest version of php 8 but I think it will take some time for the frameworks and developers to get up to speed with the latest improvements and changes.

Reply

Sebastian Sánchez

Nov 15, 2020

I think so same too

Reply

ДунканМаклауд

Oct 29, 2020

Nice read ! Thanks Hristo !

Reply

Allan C. Tidalgo

Oct 29, 2020

Job, well done!!!

Reply

Jhuly

Nov 02, 2020

Php8 exist Named arguments rfc Named arguments allow you to pass in values to a function, by specifying the value name, so that you don't have to take their order into consideration, and you can also skip optional parameters!

Reply

Ziv Li

Nov 06, 2020

Big important thing is “faster code execution”

Reply

Manomite

Nov 21, 2020

Hummm!!! This is a great developments...to trusted and faithful PHP developers like me whom never gave up on PHP... Despite the odds and disagreements from many communities... People miss interpretes the use of PHP when it comes to security loopholes... PHP has always been secured... The bad dev. never understood this... Even ASP or Java could be hacked if not properly written by professional developers. With the arrive of PHP 8.0 and it's new features I believed many tools will be developed starting from ML libraries... Since this new version is much more faster..

Reply

Patrick

Nov 26, 2020

Awesome, can't wait for PHP 8! Really looking forward to union types, attributes and the additional sugar!

Reply

Philippus

Nov 26, 2020

A new elephpant sounds nice, as do union types. It'll be interesting to see how they will/can be used.

Reply

Ramona

Nov 26, 2020

I came home some minutes ago and with the PHP8 Release I'm excited to experience the performance improvements and the possibilities to write cleaner Code. In addition, I'm eager to see what PHP8 will mean in context of unit testing. Lots of things to discover. ❤️

Reply

Martin

Nov 26, 2020

I'm most excited about and looking forward to all the small things that were done to make PHP a stricter language and enable more type safety. Next would be the JIT, attributes and the nullsafe operator (mostly in legacy code bases and libraries or APIs that have too many nullable returns for my opinion..)

Reply

Grummfy

Nov 27, 2020

PHP8 give union type and named argument. But the most wanted feature is the constructor properties that will really something so helpfull. But otherwise, the main feature that will change everything, for me the match expression. It's the feature that open nice possibilities.

Reply

Start discussion

Ready to get your website started?

Choose a hosting plan, start or migrate your site in a few clicks, and grow your online presence!

Get Started Chat with an expert