要呼叫控制器I使用這樣的CURL請求:呼叫Laravel控制器,並通過HTTP標頭它
curl -kX POST https://site/method -H 'Authorization: Bearer ACCESS_TOKEN\
Content-Type:application/json' -d '
{
"param1":"value 1",
"param2":"value 2",
"param3":"value 3"
}'
的呼叫路由UserController的@方法。
如何從Laravel代碼(內部請求,不發送CURL)執行相同操作?
我發現用這樣的
$controller = app()->make($controllerName);
$response = app()->call([$controller, 'method'], []);
echo $response;
其中最後[]應該包含一些參數的建議。但如果是這樣的話,我無法弄清楚陣列應該如何看待我的情況。
P.S.請不要回答「這是一個壞習慣」,而不是給出建議如何實施我所需要的。