After upgrading to Magento version 2.4.6, many times we get an error of ZendClient class is deprecated like the following screenshot:
1 exception(s): Exception #0 (Exception): User Deprecated Functionality: Class is deprecated in /var/www/html/vendor/magento/framework/HTTP/ZendClient.php on line 27 Exception #0 (Exception): User Deprecated Functionality: Class is deprecated in /var/www/html/vendor/magento/framework/HTTP/ZendClient.php on line 27 <pre>#1 trigger_error() called at [vendor/magento/framework/HTTP/ZendClient.php:27] #2 Magento\Framework\HTTP\ZendClient->__construct() called at [vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121] #3 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() called at [vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66]
For the solution, we can use LaminasClient class. Laminas\Http\Client class has the following method which replaces ZendClient class methods.
| ZendClient Methods | LaminasClient Methods |
|---|---|
| setUri() | setUri() |
| setConfig(array()) | setOptions(array()) |
| setHeaders() | setHeaders() |
| setRawData() | setRawBody() |
| request($method) | send() (before use send(), you need set method with function setMethod($method) first |
| isSuccessful() | isSuccess() |
| getStatus() | getStatusCode() |
You can refer to more methods for LaminasClient class located at vendor/laminas/laminas-http/src/Client.php.
We hope this blog may be understandable and useful to you. You can email us at mage2developer@gmail.com if we missed anything or want to add any suggestions. We will respond to you as soon as possible. Happy to help 🙂


