dev-master
9999999-dev http://sargilla.com.arPHP Curl library for the Laravel 5
MIT
The Requires
- illuminate/support >=4.0
- php >=5.4.0
laravel curl sargilla
PHP Curl library for the Laravel 5
Custom PHP cURL library for the Laravel 5 framework, (*1)
Pull this package in through Composer., (*2)
{ "require": { "sargilla/curl": "dev-master" } }
Add the service provider to your config/app.php
file:, (*3)
'providers' => array( //... Sargilla\Curl\CurlServiceProvider::class, ),
Add the alias to your config/app.php
file:, (*4)
'aliases' => array( //... 'Curl' => Sargilla\Curl\Facades\Curl::class, ),
Create a new instance of the CurlService
where you would like to use the package:, (*5)
$curlService = new \Sargilla\Curl\CurlService();
The package provides an easy interface for sending cURL requests from your application. The package provides a fluent interface similar the Laravel query builder to easily configure the request. There are several utility methods that allow you to easily add certain options to the request., (*6)
In order to send a GET
request, you need to use the get()
method that is provided by the package:, (*7)
// Send a GET request to: http://www.foo.com/bar // Send a GET request to: http://www.foo.com/bar?foz=baz // Send a GET request to: http://www.foo.com/bar?foz=baz using JSON
Post requests work similar to GET
requests, but use the post()
method instead:, (*8)
// Send a POST request to: http://www.foo.com/bar // Send a POST request to: http://www.foo.com/bar // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON and return as associative array
For downloading a file, you can use the download()
method:, (*9)
// Download an image from: file http://www.foo.com/bar.png
Usage without Laravel is identical to usage described previously. The only difference is that you will not be able to
use the facades to access the CurlService
., (*10)
$curlService = new \Sargilla\Curl\CurlService(); // Send a GET request to: http://www.foo.com/bar $response = $curlService->to('http://www.foo.com/bar') ->get(); // Send a POST request to: http://www.foo.com/bar $response = $curlService->to('http://www.foo.com/bar') ->post();
This template is open-sourced software licensed under the MIT license, (*11)
Santiago Argilla (developer), (*12)
PHP Curl library for the Laravel 5
MIT
laravel curl sargilla