在安装软件包I want like this之前,一切工作正常。
现在,我在添加新路线时收到404错误。
旧路线运行正常,但新路线无法运行
Web.php
//old routes
Route::get('/', function () {
return view('welcome'); //working
});
Route::get('email', 'EmailController@sendEmail'); /working
Route::get('/counter',function() {
$counter = Redis::incr('counter'); //working
return $counter;
});
//new routes
//Firebase admin SDK
Route::get("fire","FirebaseSdkController@fire");
Route::get("say-hello", function(){
return "hello";
});
FirebaseSdkController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Kreait\Firebase;
use Kreait\Firebase\Messaging\CloudMessage;
class FirebaseSdkController extends Controller
{
public function fire()
{
$firebase = (new Firebase\Factory())->create();
$messaging = $firebase->getMessaging();
$topic = 'News';
$message = CloudMessage::withTarget('topic', $topic)
->withNotification("Hello") // optional
// ->withData($data) // optional
;
$message = CloudMessage::fromArray([
'topic' => $topic,
'notification' => [/* Notification data as array */], // optional
'data' => [/* data array */], // optional
]);
$messaging->send($message);
}
}
这是我到目前为止尝试过的-
php artisan route:list
在列表中显示新路线
php artisan route:clear
php artisan config:clear
composer dump-autoload
他们都没有解决问题。
更新
现在,如果删除任何路由并执行php artisan route:clear
,我仍然可以访问该路由。我不知道发生了什么,请帮忙。