我几天前才开始学习PHP,如果这个问题是新手,请原谅我。我的 CRAWLER_URI 声明有什么问题?在env()
方法之外不起作用,我不知道为什么。
namespace App\Http\Controllers;
use GuzzleHttp\Client;
class SpotifyController extends Controller
{
const CRAWLER_URI = env('CRAWLER_URI') . ':' . env('CRAWLER_PORT');
/**
* Send a GET to Crawler API
* @return a json crawled by an external API crawler
*/
public function fetch()
{
$client = new Client(['base_uri' => self::CRAWLER_URI]);
$response = $client->request('GET');
dd($response);
}
}