【发布时间】:2021-01-13 16:46:30
【问题描述】:
我正在尝试从 laravel 8 应用发送通知。” 当我点击 URL 时,我得到了错误。语法错误,意外的 ')' 在路由文件中:
Route::get('/twitter', function (){
Notification::route(TwitterChannel::class,'')->notify(new TestNotification());
});
在通知文件中
public function via($notifiable) {
return [TwitterChannel::class];
}
public function toTwitter($notifiable)
{
return new TwitterStatusUpdate('Laravel notifications are awesome!');
}
在 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"
},
错误页面截图是: The error page screenshot
【问题讨论】:
-
您使用的 PHP 版本错误
-
首先使用 php -v 检查你的 php 版本。这不会一直打印准确的 php 版本。这就是为什么你应该使用 在代码中