We've released PHP 8.0 support on our platform
PHP 8.0 was released on the 26th of November 2020. A new version many developers have been waiting for! PHP 8.0 is the new main version, meaning that it includes some important adjustments, new features and performance improvements.
For users of previous PHP versions, an upgrade to PHP 8.0 may require some adjustments into the code. If you kept your PHP releases and updates up-to-date, the upgrade should not lead to too much effort.
Improvements and new features of PHP 8.0
PHP 8.0 will not only provide you with some adjustments, but will also bring a nice set of new features, for example the JIT-compiler, union types, attributes and even more. Below, you can read briefly about the improvements and new features of PHP 8.0:
Since 2011, PHP has been working on integrating JIT into PHP to ensure performance improvements. All three different attempts of integrating JIT did not result in a release. However, it finally succeeded in the release of PHP 8.0.
JIT is a technique that compiles parts of the code during runtime, so that the compiled version can be used instead.
There is a monitor that takes a look at the code while it is running. If this monitor detects parts of your code that are being loaded again, it marks those parts as “warm” or “hot”, depending on the frequency. These “warm” parts can be compiled as optimized machine code which can be directly used instead of the real code.
The JIT - Just In Time - compiler promises considerable performance improvements, although not always within the context of web requests. Those performance improvements cannot always be seen clearly in every PHP application. How big the difference is depends on how your application is written. However, this new functionality brings possibilities for further improvements to your applications.
Until the release of PHP 8.0, there was no support for union types, except the ‘?Type’ and special type ‘iterable’. With the release of PHP 8.0, union types can be used for accepting values of different types.
This will be explained by Nikita Popov in RFC.
“Supporting union types in the language allows us to move more type information from phpdoc into function signatures, with the usual advantages this brings:
- Types are actually enforced, so mistakes can be caught early.
- Because they are enforced, type information is less likely to become outdated or miss edge-cases.
- Types are checked during inheritance, enforcing the Liskov Substitution Principle.
- Types are available through Reflection.
- The syntax is a lot less boilerplate-y than phpdoc.”
Specifying properties for objects, elements or files can be done with attributes, also known as annotations.
The only way to add metadata until PHP 7.4 was through ‘doc-comments’ The new Attributes v2 RFC introduces attributes to define them as a form of structured, syntactic metadata. These can be added to declarations of classes, properties, methods, parameters and constants.
More new elements in PHP 8.0
In addition to the improvements and new features we have mentioned above, PHP 8.0 even consist of more improvements, for example:
- Constructor Property Promotion
- Validation for abstract trait methods
- Incompatible method signatures
- Arrays starting with a negative index
- Consistent type errors for internal functions
- Throw Expression
- Weak Maps
- Trailing comma in parameter list
- ::class allowed for objects
- New PHP functies
- str_starts_with() and str_ends_with()
PHP 8.0 support on the Hipex platform
To further improve the performance of our customers, PHP 8.0 can’t be lacking on our platform. Since the release of PHP 8.0, we have prepared ourselves for the support of PHP 8.0 behind the scenes. From now on, we have released this support and customers can use PHP 8.0 if desired.
Top 5 meest gelezen
Volg ons op social media
Hypersnelle e-commerce hosting
Snellere website = betere conversie
Probeer onze hypersnelle hosting 30 dagen gratis uit en ontvang een vergelijkingsrapport met je huidige hosting.
- Tot 30 dagen gratis uitproberen
- Performance analyse
- Vergelijkingsrapport huidige hosting
- Beste hosting van Nederland
Start 30 Day Trial