Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alixaxel/curly
Asynchronous cURL Wrapper for PHP
https://github.com/alixaxel/curly
Last synced: 3 days ago
JSON representation
Asynchronous cURL Wrapper for PHP
- Host: GitHub
- URL: https://github.com/alixaxel/curly
- Owner: alixaxel
- License: mit
- Created: 2014-09-16T23:30:19.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-17T16:24:15.000Z (about 10 years ago)
- Last Synced: 2024-10-11T20:14:36.758Z (28 days ago)
- Language: PHP
- Homepage:
- Size: 172 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/alixaxel/curly.svg?branch=master)](https://travis-ci.org/alixaxel/curly/)
#curly
Parallel cURL Wrapper for PHP
##Requirements
- PHP 5.4+
- cURL Extension##Installation (via Composer)
Add the following dependency in your composer.json file:
```json
{
"require": {
"alixaxel/curly": "*"
}
}
```And then just run `composer install` or `composer update`.
##Usage (Single Requests)
```php
sprintf('@', __FILE__),
'bar' => 'baz',
];var_dump(CURL::Uni($url, $data, 'POST'));
```##Usage (Multiple Requests)
```php
sprintf('@', __FILE__),
'bar' => 'baz',
];$handles = [];
for ($i = 0; $i < 16; ++$i)
{
$handles[$key = uniqid()] = CURL::Uni($url, $data, 'POST', null, null, 0);
}$parallel = 4; // number of requests to make in parallel
$throttle = 1; // wait at least 1 second per each $parallel requestsprint_r(CURL::Multi($handles, null, $parallel, $throttle)); // original keys are preserved
```##Usage (Multiple Requests with Callback)
```php
sprintf('@', __FILE__),
'bar' => 'baz',
];$handles = [];
for ($i = 0; $i < 16; ++$i)
{
$handles[$key = uniqid()] = CURL::Uni($url, $data, 'POST', null, null, 0);
}$parallel = 4; // number of requests to make in parallel
$throttle = 1; // wait at least 1 second per each $parallel requests$result = CURL::Multi($handles, function ($response, $info, $id) {
var_dump($id, $response);
}, $parallel, $throttle);print_r($result); // each key will have the return value of the lambda callback
```##Changelog
- **0.1.0** ~~initial release~~
- **0.2.0** ~~added XPathify() utility method~~##Credits
`XPathify()` is based on [visionmedia/php-selector](https://github.com/visionmedia/php-selector/).
##License (MIT)
Copyright (c) 2014 Alix Axel ([email protected]).