I just start learning PHP few days ago so forgive me if this question is a newbie one.
What is wrong with my declaration of CRAWLER_URI ? The env()
isn't working outside a method and I don't know why.
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);
}
}