Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Solution-Guzzle idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

Solution-Guzzle idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated


Guzzle is a PHP package that use by many frameworks like CakePHP. With PHP > 7, guzzlehttp gives an Error like idn_to_ascii()  is Deprecated. So we can solve these issues by

1) Downgrade Guzzle
2) Reinstall Packages
3) Upgrade PHP Version

If your issue still exists and then we can try to avoid deprecated errors by adding @ before idn_to_ascii() function, it will prevent to generate deprecation errors for this function. Yes we do not make changes in vendor files and also it's not a good way to handle error but sometimes it works
and that's all we wanna do.

Example:
For me its showing error like

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated
[ROOT/vendor/guzzlehttp/guzzle/src/Utils.php, line 35]


SO i have opened Utils.php file and added @ before function like below code
BEFORE
 public static function idnUriConvert(UriInterface $uri, $options = 0)
{
if ($uri->getHost()) {
$idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0;
$asciiHost = $idnaVariant === 0
? idn_to_ascii($uri->getHost(), $options)
: idn_to_ascii($uri->getHost(), $options, $idnaVariant, $info);
AFTER

public static function idnUriConvert(UriInterface $uri, $options = 0)
{
if ($uri->getHost()) {
$idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0;
$asciiHost = $idnaVariant === 0
? @idn_to_ascii($uri->getHost(), $options)
: @idn_to_ascii($uri->getHost(), $options, $idnaVariant, $info);


Important Links

Guzzlehttp error

Guzzle deprecated error

Laravel, codeigniter, cakephp idn_to_ascii() deprecated error.




This post first appeared on Thecoderain PHP,wordpress,cakephp,codeigniter,js, Jquery, Ajax Free Tutorials, please read the originial post: here

Share the post

Solution-Guzzle idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

×

Subscribe to Thecoderain Php,wordpress,cakephp,codeigniter,js, Jquery, Ajax Free Tutorials

Get updates delivered right to your inbox!

Thank you for your subscription

×