2017 © Pedro Peláez
 

library curl

PHP Curl library for the Laravel 5

image

sargilla/curl

PHP Curl library for the Laravel 5

  • Monday, May 30, 2016
  • by sargilla
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Sargilla/Curl

Custom PHP cURL library for the Laravel 5 framework, (*1)

Installation

Pull this package in through Composer., (*2)


{ "require": { "sargilla/curl": "dev-master" } }

Laravel 5.* Integration

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, ),

Integration without Laravel

Create a new instance of the CurlService where you would like to use the package:, (*5)


$curlService = new \Sargilla\Curl\CurlService();

Usage

Laravel usage

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)

Sending GET requests

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

Sending POST requests

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

Downloading files

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

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();

License

This template is open-sourced software licensed under the MIT license, (*11)

Contact

Santiago Argilla (developer), (*12)

  • Email: sargilla@gmail.com

The Versions

30/05 2016

dev-master

9999999-dev http://sargilla.com.ar

PHP Curl library for the Laravel 5

  Sources   Download

MIT

The Requires

 

laravel curl sargilla