【问题标题】:Getting parse error when i try to send reset password link in laravel当我尝试在 laravel 中发送重置密码链接时出现解析错误
【发布时间】:2018-06-27 02:28:37
【问题描述】:

我正在使用Laravel 5.4。当我尝试请求 password reset link 时出现错误。

Symfony\Component\Debug\Exception\FatalThrowableErrorPOST /password/email 解析错误:语法错误,意外 '?',期待 变量(T_VARIABLE)

错误指向的文件是这个(在'return $next($request)'

app/Http/Middleware/RedirectIfAuthenticated.php:24App\Http\Middleware\RedirectIfAuthenticated::handle

 namespace App\Http\Middleware;
 use Closure; 
 use Illuminate\Support\Facades\Auth;

 class RedirectIfAuthenticated {
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect('/');
     }

     return $next($request);
 } 
}

我对代码进行了进一步调试,发现这个函数会导致问题。
文件名:Symfony\Component\CssSelector\XPath\Extension\AttributeMatchingExtension

public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
{
    return $xpath->addCondition($attribute);
}

【问题讨论】:

  • 什么是 $next?和$请求。 $next seems a variable 但您将其视为一个函数。你能告诉我
  • 向我们展示您的重置密码和控制器代码的电子邮件视图
  • 它的 laravel 默认中间件,用于在用户不是访客时重定向请求。
  • 缺少extends Middleware
  • @Sohel0415,我正在使用默认的 laravel 用户登录和密码重置机制,我尝试调试代码并且请求从中间件重定向。 (我尝试在这种方法中调试 App\Http\Controllers\Auth\ResetPasswordController@reset )

标签: php laravel symfony


【解决方案1】:

我在使用 php mail() 函数的 php 7.0.23 和 Laravel 5.5 中遇到了同样的问题:

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) at [...]/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php:46

问题已通过升级到版本php 7.1 解决。 (它也适用于php 7.2

【讨论】:

  • 这也解决了我的问题,将php7.0升级到php7.1.*
猜你喜欢
  • 2022-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多