ixudra / curl

Custom PHP curl library for the Laravel 5 framework - developed by Ixudra
MIT License
561 stars 128 forks source link

Class Curl does not exist #14

Closed emmanesguerra closed 8 years ago

emmanesguerra commented 8 years ago

Hi I have followed the instruction on how to install Ixudra\Curl, but unfortunately I can't make it work.

if I use this bunch of code as test script

$response = Curl::to('http://www.foo.com/bar') ->get(); return $response;

It returns "Class Curl does not exist"

I have tried adding these at the top, but still it is not working.

use Ixudra\Curl\Facades\Curl;

and

use Ixudra\Curl\;

What am I missing? Also, i'm done running the composer update

elimentz commented 8 years ago

If you're using Laravel and you've completed the installation procedure correctly (i.e. you've added the CurlServiceProvider and the Facade class to your config/app.php file), you need to add use Curl; to the top of your file. Alternatively, you can also do it without the use statement:

$response = \Curl::to('http://www.foo.com/bar') ->get(); 

return $response;

If you're not using Laravel, you need to create a new instance of the CurlService and access it as you would any other class:

    use Ixudra\Curl\CurlService;

    $curlService = new CurlService();

    // Send a GET request to: http://www.foo.com/bar
    $response = $curlService->to('http://www.foo.com/bar')
        ->get();