27Laracurl Laravel wrapper package for PHP cURL class that provides OOP interface to cURL. [10/27/2015] View Details

Related tags

Laravel Laracurl
Overview

Laracurl

Laravel cURL Wrapper for Andreas Lutro's OOP cURL Class

Installation

To install the package, simply add the following to your Laravel installation's composer.json file

"require": {
	"laravel/framework": "5.*",
	"zjango/laracurl": "dev-master"  
},

Run the usual composer update to pull the files. Then, add the following Service Provider to your providers array in your config/app.php config.

'providers' => array(
	...
	'Zjango\Laracurl\LaracurlServiceProvider',
);

And finally add a new line to the aliases array:

		'Laracurl'	=>	'Zjango\Laracurl\Facades\Laracurl',

Usage

Simple GET Request

$response = Laracurl::get('http://www.google.com');

Easily Build URL With Query String Attached

$url = Laracurl::buildUrl('http://www.google.com', ['s' => 'curl']);
$response = Laracurl::get($url);

post() accepts array of POST data

$url = Laracurl::buildUrl('http://api.somedomain.com', ['token' => 'token_val']);
$response = Laracurl::post($url, ['post' => 'data']);

Prefix 'json' to method to post as JSON

$response = Laracurl::jsonPut($url, ['post' => 'data']);

Prefix 'raw' to method to post as JSON

$response = Laracurl::rawPost($url, 'raw string data ...');

###The Response Object###

The $response variable in above examples represents an object as well.

// Return Headers
$response->headers

// Return Status Code
$response->code

// Response Body
$response->body

// cURL Info
$response->info

####Response Headers example####

var_dump($response->headers);

array (size=22)
  'HTTP/1.1' => string '200 OK' (length=6)
  'Server' => string 'nginx/1.5.11' (length=12)
  'Date' => string 'Thu, 10 Jul 2014 02:25:01 GMT' (length=29)
  'Content-Type' => string 'application/json; charset=UTF-8' (length=31)
  'Transfer-Encoding' => string 'chunked' (length=7)
  'Connection' => string 'keep-alive' (length=10)
  'Status' => string '200 OK' (length=6)
  'X-API-Version' => string 'v2' (length=2)
  'X-Frame-Options' => string 'SAMEORIGIN' (length=10)
  'X-Origin-Server' => string 'app.pod1.ord.sample.com' (length=24)
  'X-UA-Compatible' => string 'IE=Edge,chrome=1' (length=16)
  'ETag' => string 'W/"a73bb2edsaerde0c55329aa2f6f"' (length=36)
  'Cache-Control' => string 'must-revalidate, private, max-age=0' (length=35)
  'X-User-Id' => string '690632553' (length=9)
  'X-Request-Id' => string 'a5d69e2sd21f53cbd5c822727f15c66c0' (length=32)
  'X-Runtime' => string '0.143530' (length=8)
  'X-Rack-Cache' => string 'miss' (length=4)
  'X-Request-Id' => string '3b1as23718db6268b9f972' (length=20)
  'X-Content-Type-Options' => string 'nosniff' (length=7)
  'X-Varnish' => string '1388807397' (length=10)
  'Age' => string '0' (length=1)
  'Via' => string '1.1 varnish' (length=11)
var_dump($response->code);

string '200 OK' (length=6)
var_dump($response->body);

string '{"ticket":{"url":"https://sample.domain.com/api/tickets/44.json","id":44,"external_id":null'... (length=3192)
var_dump($response->info);

array (size=23)
  'url' => string 'https://sample.domain.com/api/tickets/44.json' (length=59)
  'content_type' => string 'application/json; charset=UTF-8' (length=31)
  'http_code' => int 200
  'header_size' => int 676
  'request_size' => int 89
  'filetime' => int -1
  'ssl_verify_result' => int 0
  'redirect_count' => int 0
  'total_time' => float 0.271805
  'namelookup_time' => float 0.000958
  'connect_time' => float 0.002369
  'pretransfer_time' => float 0.050838
  'size_upload' => float 0
  'size_download' => float 3192
  'speed_download' => float 11743
  'speed_upload' => float 0
  'download_content_length' => float -1
  'upload_content_length' => float 0
  'starttransfer_time' => float 0.271732
  'redirect_time' => float 0
  'certinfo' => 
    array (size=0)
      empty
  'primary_ip' => string 'xx.xxx.xxx.xx' (length=14)
  'redirect_url' => string '' (length=0)
You might also like...
Laravel Soulbscription - This package provides a straightforward interface to handle subscriptions and features consumption.

About This package provides a straightforward interface to handle subscriptions and features consumption. Installation You can

A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class

Changelog Update support for Laravel 6 & phpunit 8 Update composer.json Upgrade to PSR-4 add parameter newline, delimiter, enclosure, and escape to ex

Stash view is a composer package for Laravel which caches views using Russian Doll Caching methodology.
Stash view is a composer package for Laravel which caches views using Russian Doll Caching methodology.

Stash View Stash view is a composer package for Laravel which caches views using Russian Doll Caching methodology. What is Russian Doll Caching ? It i

A package that adds view-composer like feature to Inertia.js Laravel adapter

Kinetic A package that adds view-composer like feature to Inertia.js Laravel adapter. Use to be able to share props based on the Inertia component nam

A package that helps to group methods that mostly use for the view presentation purpose.

A package that helps to group methods that mostly use for the view presentation purpose form models to a dedicated presenter class.

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

Introduction Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerpl

Laravel Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

Introduction Laravel Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services. It handles almost all of the b

View template engine of PHP extracted from Laravel

Blade 【简体中文】 This is a view templating engine which is extracted from Laravel. It's independent without relying on Laravel's Container or any others.

A simple `make:view` command for Laravel applications.

A simple make:view command for Laravel applications. Quickly generate a new Blade view from the console using artisan make:view. Installation You can

Comments
  • Copyright infringement

    Copyright infringement

    Hello,

    Somsone notified me about this package today. It seems to me you've copied the contents of my repository from a few months back, changed the code style, removed/replaced the licensing information and published it on packagist and packalyst.

    Frankly, I don't quite see the point of a Laravel "wrapper" (though it is more of a replacement than a wrapper), since my original package supports Laravel just fine.

    I won't bother trying hard to enforce my copyright, but I don't think it's benefitial for users of packagist/packalyst/whatever to find and use this package.

    If you have suggestions for improvements I'd be happy to hear them out and consider implementing them in my original package.

    opened by anlutro 0
Owner
zjango
zjango
Laravel Composable View Composers Package - Compose View Composers from Component Composers

Laravel Virtuoso Laravel Composable View Composers Package Increase flexibility and reduce code duplication by easily composing complex View Composers

Yitzchok Willroth 68 Dec 29, 2021
Laravel Authentication Log is a package Log user authentication details and send new device notifications.

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

Anthony Rappa 540 Jan 5, 2023
This package provides a Logs page that allows you to view your Laravel log files in a simple UI

A simplistics log viewer for your Filament apps. This package provides a Logs page that allows you to view your Laravel log files in a simple UI. Inst

Ryan Chandler 9 Sep 17, 2022
This package provides a Filament resource to view all Laravel sent emails.

This package provides a Filament resource to view all Laravel outgoing emails. It also provides a Model for the database stored emails. Installation Y

Ramón E. Zayas 22 Jan 2, 2023
Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string template and recompiles it if needed.

Laravel-fly-view Is an Extension of Laravel View Class which compiles String Template on the fly. It automatically detects changes on your string temp

John Turingan 16 Jul 17, 2022
Razorpay payment gateway integration in laravel with submit form and storing details in payment table.

Integrating razorpay payment gateway in laravel with submit form and storing payment details in payment table. How to settup the project in your local

Mohammed-Thamnees 3 Apr 15, 2021
A blog website with blog details with laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

PreshDev 3 Mar 6, 2022
Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

null 686 Dec 28, 2022
ODM with inheritance and OOP composition for Laravel 5+

ODM with inheritance and OOP composition for Laravel 5+ Full Documentation | CHANGELOG LODM module is intended to bring the Spiral ODM component funct

Anton Titov 21 Aug 17, 2022
Interact with posts, terms & users in a OOP way

Installation composer require tombroucke/wp-models Interacting with models Create a new class for your custom post type namespace Otomaties\Events\Mod

null 2 Jul 14, 2022