Laravel弃用错误:idn_to_ascii():INTL_IDNA_VARIANT_2003已弃用 [英] Laravel Depreciated Error: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

查看:36
本文介绍了Laravel弃用错误:idn_to_ascii():INTL_IDNA_VARIANT_2003已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Laravel版本是6.我的注册表格无法在实时服务器上运行,但对于本地主机来说却很好.当我点击注册按钮时,它将引发此异常.

My Laravel version is 6. My registration form is not working on live server but it's working good for localhost. When I hit register button, it throws this exception.

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

它在第114行上指向我的RegisterController.php.

It's pointing out to my RegisterController.php on line 114.

$this->validator($request->all())->validate();

和这行vendor/guzzlehttp/guzzle/src/Utils.php:35

and this line vendor/guzzlehttp/guzzle/src/Utils.php:35

? idn_to_ascii($uri->getHost(), $options)

RegisterController.php

RegisterController.php

class RegisterController extends Controller
{
    use RegistersUsers;

    protected $redirectTo = RouteServiceProvider::HOME;

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function validator(array $data)
    {
        $validator = Validator::make($data, [
            'register_name' => ['required', 'string', 'max:8'],
            'register_email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
            'register_password' => ['required', 'string', 'min:8', 'confirmed'],
            'user_type'=> ['required','in:user,company'],
            'g-recaptcha-response' => ['required','captcha'],

        ]);
        $validator->setAttributeNames([
            'register_email' => 'email',
            'register_password' => 'password',
        ]);

        return $validator;
    }
    protected function create(array $data)
    {
      $user = User::create([
          'name' => $data['register_name'],
          'email' => $data['register_email'],
          'password' => Hash::make($data['register_password']),
          'user_type' =>$data['user_type'],

      ]);

      $user->sendEmailVerificationNotification();

      return $user;
    }

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
            ?: redirect()->intended($this->redirectPath());
    }

}

推荐答案

我在服务器上安装了php7.3.而且我遇到了同样的错误.但是赫里,我解决了我的问题.

I have php7.3 on my server. and I was getting the same error. But hurrey, I fixed my problem.

当我们使用此命令在Laravel应用中安装guzzle时

When we install guzzle in our Laravel app using this command

composer require guzzlehttp/guzzle

它安装了比^ 7更低的guzzle版本.并且要解决此问题,我们需要最新的版本,在撰写本文时为^ 7.0.

It install lower version of guzzle than ^7. and to fix this problem, we need latest guzzle version, which is ^7.0 at the time of writing this post.

所以,有解决方案.

在服务器上编辑您的composer.json文件.并像这样更新您的枪口版本.

Edit your composer.json file on the server. and update your guzzle version like this.

"guzzlehttp/guzzle": "^7.0",

然后在服务器终端上运行命令.

then run the command on your server terminal.

composer update

就是这样.

如果您的PC上没有连接服务器ssh,则可以更新本地项目并重新上传整个供应商目录.

If you don't have server ssh connected to your pc, you can update your local project and re-upload the whole vendor directory.

这篇关于Laravel弃用错误:idn_to_ascii():INTL_IDNA_VARIANT_2003已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆