语法错误,laravel 8 中意外的“)”。\vendor\laravel\framework\src\Illuminate\Bus\BusServiceProvider.php:51

Kho*_*yer 1 php laravel laravel-8

我正在尝试从 laravel 8 应用程序发送通知。” 当我点击 URL 时,我收到错误消息。语法错误,意外的 ')' 在路由文件中:

Route::get('/twitter', function (){
    Notification::route(TwitterChannel::class,'')->notify(new TestNotification());
});
Run Code Online (Sandbox Code Playgroud)

在通知文件中

public function via($notifiable)  {
    return [TwitterChannel::class];
}
public function toTwitter($notifiable)
{
    return new TwitterStatusUpdate('Laravel notifications are awesome!');
}
Run Code Online (Sandbox Code Playgroud)

在 composer.json 文件中

"require": {
    "php": "^7.3",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel-notification-channels/twitter": "^5.0",
    "laravel/framework": "^8.0",
    "laravel/tinker": "^2.0"
},
Run Code Online (Sandbox Code Playgroud)

错误页面截图为: 错误页面截图

lag*_*box 12

Laravel 8 需要 PHP >= 7.3。您使用的版本低于那个版本,这就是为什么它不支持函数调用中的尾随逗号。

错误是您使用错误版本的证据。

PHP.net 手册 - 7.3 特性 - 调用中允许尾随逗号

  • 您使用了错误的版本...您的系统上有多个版本(7.4 正是 C​​LI 使用的版本)...错误再次证明 (2认同)