Blog

Having a great design idea for your application or not, our artistic team of designers will help you formulate an impressive one.

PHP 7.3 eol

PHP 7.4 EOL: Things to know after PHP 7.4 EOL, how to update to 8.0

PHP 7.4 EOL: Update to the latest version

PHP 8.2 is the next PHP 8 minor release, released on November 24th, 2022. So let's take a look at some of the most exciting new additions and features that will make PHP faster and more reliable. Even though PHP 8.1 significantly improves performance and code readability, PHP 8.2 will be the true benchmark for PHP performance. Besides new features, the language has undergone significant changes. The majority of these changes are non-breaking, but some may have an impact on your code bases.

Deprecation warnings are not, by definition, "breaking". but rather serve as a warning to the developer that functionality will be removed or changed in the future. It is best not to ignore deprecation warnings and fix them as soon as possible, making the upgrade path to PHP 8.0 easier. Before talking about 8.2 let's discuss the difference between PHP 7.4 and PHP 8.0
 

Table of contents

What is the difference between PHP 7.4 and PHP 8.0?
 

PHP 7.4

PHP 7.4  is the most recent stable version. It was released on November 28, 2019, and is the final version before PHP 8. It includes numerous new features, syntax additions, and bug fixes.

Features:

  • Typed properties are supported.
  • Arrow functions are supported.
  • Contravariant Parameters and Covariant Returns
  • Operator Support for Coalescence Assignment
  • References that are inadequate Support
  • Deprecations of the preloading and propagation operators in array expressions
     

PHP 8.0

In comparison to PHP 7, PHP 8 introduces a host of new features, enhancements, functions, and deprecations to the language.

Features:

  • Just-In-Time (JIT) Compiler
  • The nullsafe operator
  • Named arguments
  • Attributes
  • Match expression
  • Inheritance with private methods
  • Weak Maps
  • Type annotations for internal functions
  • ext-JSON always available
  • Consistent type errors
     

The Features of PHP 7.4

PHP 7.4 is the most recent stable version. It was released on November 28, 2019, and is the final version before PHP 8. It includes numerous new features, syntax additions, and bug fixes.

This post contains a list of everything new and changed to help you prepare for the upgrade. But first, let's look at some of the highlights of PHP 7.4.

  • For cleaner one-liner functions, use arrow functions.
  • Preloading for better performance
  • Class properties that are typed
  • Increased type variance
  • As a shortcut, the null coalescing assignment operator
  • FFI for better PHP extension development
  • Numeric values can be formatted using underscores.
  • Array spread operator
     

When will PHP 7.4 EOL?

PHP 7.4 will reach end-of-life (EOL) on November 28, 2022, which means that known security issues will no longer be addressed, leaving sites vulnerable to serious security vulnerabilities.

They must be updated to a newer version. We recommend upgrading to either8.0/8.1. PHP 8.0 is supported till November 26, 2023, and 8.1 is supported till November 25, 2024. New major PHP versions provide a slew of new features as well as some incompatibilities. Before switching PHP versions in production situations, these should be tested. For the new PHP supportability, you may need to have your developers update some code, as well as check plug-ins and app versions
 

What do we do if PHP 7.4 comes to an end?

PHP 7 was first released in 2015. Currently, 68.9 per cent of all PHP-powered websites are still using one of the 7.4 versions. PHP 8 has been available since November 2020, but only 1% of websites have made the switch. Using outdated software is rarely a good idea. The older the software, the more likely it has flaws, obsolete functions, or a lack of developer support. That lack of support is exactly what EOL means.

When a piece of software reaches its end of life, developers stop providing support, major updates, and security patches. As a result, if you continue to use that outdated version, you will be on your own for any problems.
 

Why do you need to upgrade to PHP 8 / 8.1?

On November 26, 2020, PHP 8 is available to the general public. This new update introduces several new features and optimizations to the language. While many RFCs have already been accepted and implemented, it's time to dive into some of the most exciting new features that have made PHP faster and more secure. You may need to improve your code to make it run on PHP 8. If you've been keeping up with the new releases, the update shouldn't be too difficult because most of the breaking changes were already deprecated in the 7. x versions. Aside from breaking changes, PHP 8.0 introduces new features such as the much-anticipated JIT compiler, union types, attributes, and much more.
 

Features of PHP 8.0 That can upgrade your performance

As a long-time PHP developer, it's a delight to see PHP 8 bring so many useful updates, such as Named Arguments, which allow you to validate data into a function based on their argument name rather than argument order. Then, in previous versions, the only way to declare union types was through PHP doc annotation comments, but these can now be made directly. All of these features are a significant improvement to the reflection API. Here are some of the exciting new PHP 8 features:
 

Just-In-Time Compiler

JIT has been available as a testing tool in PHP since v7.4, but its performance and usability have greatly improved in the PHP 8 version. JIT was available in disabled mode by design in PHP 7.4 to conduct experiments and evaluate the other variables. Because of how it handles PHP script compilation, JIT will increase the speed of PHP 8 applications. It is simple in comparison to V8, HHVM, PyPy, and other modern PHP JITs, but it increases total PHP complexity, the possibility of new bugs, and the cost of creation and maintenance. The new and improved JIT compiler, now officially supported by the PHP mechanism, allows you to execute application code faster than the traditional interpreter.
 

The nullsafe Operator

The new null safe operator? with complete short-circuiting is proposed in this RFC. If you're familiar with the null coalescing operator, you're already aware of its flaws: Method calls do not function. It would be preferable if you used intermediate checks instead of optional helpers.
 

Named Arguments

With named arguments, developers can pass values to a function by defining the value name, eliminating the need to consider their order. Optional parameters can also be ignored. Because the names of the arguments are descriptive, named arguments make the code easier to understand.
 

Matched Expression

Match expressions were the most notable feature I discovered in PHP 8 that made coding easier. Developers can now return a value based on the given input without the use of any additional keywords. It's like the switch expression's big brother: match expressions can return values, don't require break statements, can combine conditions, use strict type comparisons, and don't coerce any type.
 

Inheritance with private methods

PHP previously used public, protected, and private methods to perform the same inheritance checks. In other words, private methods should adhere to the same method signature rules as protected and public methods. As a result, children's classes would be unable to use private methods. Because of this updated PHP 8 feature, these inheritance checks are no longer performed on private methods. Furthermore, using the final private feature made no sense, so doing so would now result in a warning.
 

Weak Maps

PHP 8 includes a WeakMap implementation in PHP 7.4. WeakMap contains references to objects that do not prevent garbage collection from those objects. They also introduce caches that contain references to entity classes to improve the performance of entity relationships, such as ORMs. These entity objects cannot be garbage collected as long as this cache has a reference to them, even if the cache is the only thing referencing them.
 

Type annotations for internal functions

This had been a long-standing issue, and with all of the improvements made to PHP in previous versions, it was finally resolved. This implies that internal functions and methods will reflect the complete type of information.
 

Namespaced names being a single token

Each part of a namespace (separated by a backslash) is interpreted as a sequence of tokens by PHP. This RFC modified that behaviour, allowing reserved names to be used in namespaces.
 

ext-JSON always available

PHP can no longer be compiled without the JSON extension enabled. Because JSON is so widely used, the best developers can always rely on it being present rather than ensuring the extension exists first.
 

Default error reporting level

E ALL has replaced all but E NOTICE and E DEPRECATED. This means that many previously silently ignored errors may have existed before PHP 8's appearance. E ALL has replaced all but E NOTICE and E DEPRECATED. This means that many previously silently ignored errors may have existed before PHP 8's appearance. E ALL has replaced all but E NOTICE and E DEPRECATED. This means that many previously silently ignored errors may have existed before PHP 8's appearance.
 

Benefits of PHP 8.0 version


 

Better Performance

PHP 8.0, like any newer version, improves performance over PHP 7.4, but the biggest gains come from additions such as the Just-In-Time (JIT) compiler.
 

Just-In-Time (JIT)

JIT is a PHP 8.0 extension that improves application performance by handling PHP script compilation. Simply put, it means that more complex application code can be executed more quickly.
 

New Features

PHP 8 is packed full of changes when compared to PHP 7.4 and includes plenty of features that any PHP can make use of it. So let’s take a gander and the most important ones.
 

Attributes

Attributes (also known as annotations) provide a new way to describe and grant special behaviours to some classes. They are defined as a type of structured metadata that can be added to the class, property, function, and other declarations.
 

Named Arguments

Named arguments, an extension of existing positional parameters, were introduced in PHP 8. They imply that you can specify which of the arguments is passed simply by using a parameter name, eliminating the need to consider order.
 

Match expressions

If you've been around the programming block, you'll recognise expression matching from other languages. PHP 7 has three different versions built into it throughout its lifetime. The new match expression in PHP 8 greatly simplifies developer life by allowing you to return a value based on the given input with safer semantics than the switch operator.
 

Nullsafe Operator

If Null Reference Exceptions are the bane of your dev life, the null safe operator can help prevent them by checking if the code can be executed without errors. If you've ever needed to get a value from a multi-level nested object or write code to check if a variable was set before using it, PHP 8.0's null-safe operator will come in handy.
 

What are the features of PHP 8.1?

PHP 8.1 is a major new version of PHP that introduces several new features, improves the quality of life, and attempts to prepare PHP to phase out some of its legacy features by deprecating and restricting certain undesirable functionality.

PHP 8.1 is a continuation of PHP's progress in providing system improvements of various types. It also includes more features that promote defensive programming. Support for Enums, Fibers, never returns a type, Intersection Types, read-only properties, and first-class callable syntax are among the highlights of PHP 8.1. It also deprecates a few features, which may cause issues when upgrading legacy PHP applications to PHP 8.1.
 

Enums

Enums will be available in PHP 8.1! If you're unsure what they're for, you can learn more about them here. Enums would be a significant improvement in PHP, so I, for one, am looking forward to seeing them in PHP 8.1. To declare Enums, PHP 8.1 reserves and uses the enum keyword. The syntax is similar to that of a trait/class/interface:

Enum Syntax

enum Suit {

case Clubs

Diamonds

case Hearts

case Spades

}

Enums are declared using the enum keyword, followed by the Enum's name. Optionally, an Enum can declare string or int as backed values. Enums can also be used to extend classes and implement interfaces. Internally, at the PHP parser level, a new token named T ENUM with the value 369 has been assigned. Enums can also contain a value for each case, making them Backed Enums.
 

Declaring Enums

Enums are internally implemented on top PHP classes, and they inherit the majority of the class semantics with some additional constraints. Enums support namespaces, autoloading, methods (but not properties), implementing interfaces, and many other PHP class-related behaviours. A basic enum is simply an enum structure with the case keyword used to declare each case. With the addition of Enums in PHP 8.1, PHP now reserves "enum" as a reserved word, preventing any functions, classes, interfaces, and so on from being created with enum. Because of changes in how PHP considers reserved keywords in namespaced values, it can be part of a namespace.
 

New enum_exists function

PHP 8.1 also includes a new enum exists function for determining whether an Enum exists. Because Enums have class semantics, the class exists function also returns true for an Enum.
 

UnitEnum interface

Enums that do not have a value implement the UnitEnum interface by default.

interface UnitEnum {

public static function cases(): array;

}

Because the engine implements this interface internally, enums cannot explicitly implement it. This is only to help determine the type of an Enum. The UnitEnum::cases method returns an array of all Enum cases.
 

BackedEnum interface

If an Enum is a scalar-backed value, that Enum will automatically have an interface known as BackedEnum. Similarly to the UnitEnum interface, the BackedEnum interface cannot be explicitly implemented. Enums with Properties, Methods, and Traits. Enums are designed in such a way that they can compare one Enum case to another. Enums must be stateless, which means they cannot store properties.
 

Enums enable methods.

Methods can be included in enums. They also support static methods and standard method visibility modifiers. This has many applications, such as declaring a label(): string method that returns a user-friendly label.
 

Fibers

Fibers is a new PHP 8.1 feature that adds lightweight and controlled concurrency to PHP. A Fiber is essentially a code block that keeps its stack (variables and state) and can be started, suspended, or terminated collaboratively by the main code and the Fiber. Fibers are analogous to computer program threads. The operating system schedules threads and does not guarantee when and where threads are paused and resumed. The program itself creates, starts, suspends, and terminates fibers, allowing for fine control of both the main program execution and the Fiber execution. The main program can restart the Fiber from where it was suspended. It is critical to understand that concurrent execution does not imply simultaneous execution.

Example:

$fiber = new Fiber(function (): void {

$valueAfterResuming = Fiber::suspend('after suspending');

// …

})

$valueAfterSuspending = $fiber->start();

$fiber->resume('after resuming');
 

How will Fibers work?

A Fiber is a single final class that is similar to computer program threads. The operating system schedules threads and does not guarantee when and where threads are paused and resumed. The program itself creates, starts, suspends, and terminates fibers, allowing for fine control of both the main program execution and the Fiber execution. Nothing happens after creating a new Fiber instance with a callable. The callback will not be executed as normal PHP code until Fiber is started.

Syntax

$fiber = new Fiber(function() : void {

echo "I'm running a Fiber, yay!";

});$fiber->start(); // I'm running a Fiber, yay!

Fibers are asynchronous until you suspend them in the callback by calling Fiber::suspend(). The Fiber is paused at that expression when Fiber::suspend() is called. Local variables, array pointers, and so on are not cleared until the Fiber object is deleted from memory.
 

Example:

$fiber = new Fiber(function() : void {

Fiber::suspend()

echo "I'm running a Fiber, yay!";

})

$fiber->start(); // [Nothing happened]

$fiber->resume(); // I'm running a Fiber, yay!

This is asynchronously incorrect, but that doesn't mean your application can't do two things simultaneously. The real deal here is that the Fiber function's state is saved where it was left off. You switch between cars, each going to a different location. One of the most useful aspects of start() suspend(), and resume() is that they accept arguments.
 

Overview of upcoming version PHP 8.2

PHP 8.2 is scheduled to be released in November 2022, with PHP 8.1.5 being the most recent stable version. While it is still early, the update has received mixed reviews. Knowing what to expect, on the other hand, can help you prepare for the latest PHP version. You can understand how the update may affect development by learning about the new features and those that are being deprecated. This knowledge can also assist you in preparing for the eventual release.
 

What’s new in PHP 8.2 version

PHP 8.2 is scheduled for release by the end of 2022. The current release schedule is as follows, with General Availability (GA) scheduled for November 24, 2022:

  • June 9th: Alpha 1 will launch.
  • June 23rd: Alpha 2 will be released.
  • July 7th: Alpha 3 will be released.
  • July 19th: Feature freeze
  • July 21st: Beta 1
  • August 4th: Beta 2
  • August 18th: Beta 3
  • September 1: Candidate Release 1
  • September 15: Candidate Release 2
  • September 29: Candidate Release 3
  • October 13: Candidate Release 4
  • October 27: Candidate Release 5
  • November 10: Candidate Release 6
  • November 24: General Assembly

According to the PHP website's official documentation, there should be a few new features and deprecated functions.
 

Performance of PHP 8.2

If current release trends continue, we should be roughly halfway through the PHP 8.2 development cycle, with annual feature releases typically arriving at the end of November. Given that, I decided to test out the current state of PHP 8.2 Git and run some preliminary benchmarks to see where things stand. Memory reset peak usage, a new function in PHP 8.2, will be included. It will clear the peak memory usage returned by memory get peak usage. This function will be useful in cases where an action is invoked multiple times and the peak memory usage of each iteration is recorded. Developers will be able to use this new feature to reset the peak memory usage at any time during the request's lifetime.
 

Keep your PHP version Up to date with Spawoz

Improving your WordPress site's performance and security is difficult, but running an up-to-date version of PHP is a simple step that can bring immediate results. While some doubt PHP's future, this open-source scripting language has been a constant on the server side of WordPress development for nearly two decades. PHP has probably gotten even more embedded as a vital foundation for developing sites and boosting speed as newer versions have been launched in recent years. Spawoz Technologies works hard to ensure that our clients have access to the most recent versions of PHP, and we normally make such versions available as soon as we've completed all of our customers' site testing.

While PHP 7.4 was made accessible to all Spawoz clients following its release last year, we have now made PHP 8.0 / 8.1  available to all clients of Spawoz who wish to upgrade. Customers can now self-select PHP 8.0 / 8.1 as their PHP version as of today. Customers that are currently using PHP 7.4 can continue to use it on their existing sites; however, PHP 7.4 will be deprecated on 28 November 2022. Leaping PHP 8.0 is simple as usual, our professional technical team is here to answer concerns about upgrading and, if necessary, We will guide you through the process.
 

Conclusion

So, based on preliminary testing, PHP 8.2 continues to be faster,  only a few per cent in the various tests so far, and with slightly lower peak memory usage. Of course, as the PHP 8.2 stable release approaches. Because of the new asynchronous design and JIT compiler, PHP 8 will be much faster than PHP 7. In PHP 8, you can be able to build asynchronous applications, which will be the big deal for websites. In comparison to PHP 7, PHP 8 introduces a host of new features, enhancements, functions, and deprecations to the language.

Related Blogs

Scroll

arrowdown