Monday, March 13, 2017

cURL doesn't work inside a Laravel Configuration File

On top of one of my Laravel config file, I want do a simple curl.

<?php

    use App\CURL;
    $url = env('APP_URL').'api/current-user';
    $user = CURL::get($url);
    // dd($user); <-------------------------------null


    return [

    ...

    ];

I kept getting NULL.


I know for sure it shouldn't return NULL. I have a feeling that the config file got loaded before my CURL class, that's why I kept getting NULL.

What is the proper way to achieve somehting like that in Laravel ? What should I look into ? What is the possible work around ?

Will view composers help on this situation ?

Any hints / suggestions on this will mean alot to me.



via ihue

Advertisement