1

I'm trying to send a notification from a laravel 8 app." When I hit the URL I get the error. syntax error, unexpected ')' In the route file :

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

In notification file

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

In composer.json file

"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 is : The error page screenshot

2 Answers2

12

Laravel 8 requires PHP >= 7.3. You are using a lower version than that which is why it does not support the trailing comma in function calls.

The error is the proof that you are using the wrong version.

PHP.net Manual - 7.3 Features - Trailing Commas are allowed in Calls

lagbox
  • 48,571
  • 8
  • 72
  • 83
  • My PHP version is PHP 7.4.10 (cli) (built: Sep 1 2020 16:52:21) ( NTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies – Khondoker Eftakhar Jubayer Sep 28 '20 at 05:50
  • 3
    you are using the wrong version ... there are multiple versions on your system (7.4 is just what the CLI is using) ... again the error is the proof – lagbox Sep 28 '20 at 05:56
-1

It's seem like a comma issue on line 50 end.

Thanks

Waqar Akram
  • 107
  • 5