[Solved] Class Zend Not Found in Magento 2 After Update
Vinh Jacker | 3 days ago
The Most Popular Extension Builder for Magento 2
With a big catalog of 224+ extensions for your online store
The Class Zend Not Found error can occur in Magento 2 when the system is unable to locate the Zend framework classes. This issue can lead to functionality problems and impact the overall performance of your Magento store.
In this article, we’ll explore two effective methods, codebase and module update with Laminas and Zend framework installation in Magento to resolve this issue and ensure the smooth functioning of your Magento 2 store.
Why “Class Zend Not Found” Occurs in Magento 2 Post-Update
The Class Zend Not Found error in Magento 2.4.6 appears due to Adobe’s decision to deprecate the Zend framework within the Magento codebase.
Instead, they have switched from Zend to Laminas, a more robust and modern PHP framework. In Magento 2.4.6, the transition from the Zend framework to Laminas has implications for custom code, third-party modules, and extensions. If these rely on Zend classes, they may no longer be compatible. Specifically, the removal of the Zend framework can trigger the ‘Class Zend Not Found’ error when the system tries to use Zend classes that their Laminas counterparts have replaced.
Consequently, to resolve this issue, developers must update their codebase to use Laminas equivalents. While temporarily re-adding Zend is possible, it is not recommended.
All Errors When Class Zend Not Found After Upgrade
Here are some of the common errors, including:
- Error: Class
Zend_Json
not found. - Error: Class
Zend_Http_Client
not found. - Error: Class
Zend_Validate
not found. - Error: Class
Zend_Filter
not found.
How to Fix Class Zend Not Found in Magento 2 After Update
Approach 1: Codebase and module update with Laminas
Step 1: Laminas installation
Firstly, install the Laminas package, specifically “laminas/laminas-serializer “, by using Composer within your Magento 2 installation. This package replaces deprecated Zend classes.
You need to follow the steps below to install Laminas.
Open terminal > go to Magento 2 root > run this command
:
composer require laminas/laminas-serializer
Note that if your Magento installation already includes the Laminas package, you can skip this step.
Step 2: Replacement of Zend classes with Laminas
When the Laminas package is installed, it is time to replace the deprecated Zend classes with their corresponding Laminas classes. Follow these steps to proceed.
1. Identify the .phtml Files:
- The first step is to locate the .phtml file(s) that trigger the “Class Zend Not Found” error. These files contain the code where the Zend classes are referenced.
2. Search for Zend Class Instances:
- Within the identified .phtml files, search for instances of Zend classes mentioned in the error message. Look for class names like
\Zend_Http_Client, \Zend_Json, \Zend_Validate
, and others.
3. Replace with Laminas Classes:
- Use these mappings to replace each Zend class with the appropriate Laminas class:
Zend Classes | Laminas Classes |
---|---|
\Zend_Http_Client::POST | \Laminas\Http\Request::METHOD_POST |
\Zend_Http_Client::GET | \Laminas\Http\Request::METHOD_GET |
\Zend_Json | \Laminas\Json\Json |
\Zend_Validate | laminas-validator |
\Zend_HTTP | laminas-http |
\Zend_Filter | laminas-filter |
Update Other Functions and Classes:
Review your custom code and third-party modules for any additional Zend classes that need replacement. Update them according to the Laminas equivalents.
-
Zend Functions: \Zend_Validate::is($email, ‘EmailAddress’): This Zend function checks whether the given email address is valid.
-
Laminas Functions: \Laminas\Validator\StaticValidator::execute($email, ‘EmailAddress’): The corresponding Laminas function performs the same validation for email addresses.
Once you’ve made the necessary changes, save the modified files.
Approach 2: Zend framework installation in Magento
If updating extensions to use Laminas is not feasible, you can reintroduce the Zend Framework into Magento 2.4.6. However, be cautious, as this may introduce additional maintenance and compatibility challenges.
Running the following command to install the Zend Framework using Composer:
composer require magento/zendframework1
Remember that the official Zend Framework has rebranded as the Laminas Project, and Adobe has replaced Zend with Laminas in the core code of Magento and Adobe Commerce. Upgrading third-party modules to Laminas is recommended for long-term compatibility.
Wrap Up
In summary, the ‘Class Zend Not Found’ error occurs when the Zend framework is missing from your Magento installation.
To address this issue, you can use either of these two approaches to update your codebase and modules to use Laminas classes or reintroduce the Zend Framework into Magento 2.4.6. Furthermore, seeking guidance from a Mageplaza Magento developer or expert can also be beneficial. By following these steps, you can resolve the error and ensure seamless functionality for your Magento platform.
Hire Magento Developers
What you need to do is only describing desired features of the Magento website, we will help you to build the store that ticks all the boxes!
Get Started