bronto / php-common-helper
Installs: 212 670
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 3
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: <5
This package is not auto-updated.
Last update: 2022-01-15 08:29:21 UTC
README
This package is archived and no longer maintained.
This package contains a number of common scripts and utilities used throughout the PHP packages provided by Bronto.
Provided is a set of functional utilties and a chainable object that wraps an associative array.
Transfer
The library ships with a pretty nice cURL transfer impl
<?php
$json = new \Bronto\Serialize\Json\Standard();
$curls = new \Bronto\Transfer\Curl\Adapter();
$request = $curls->createRequest('GET', 'http://some-resource.com');
$response = $request->respond();
$data = $json->decode($response->body());
$multi = new \Bronto\Transfer\Curl\Multi();
// Below are the defaults
$multi
->setMaxConnections(10)
->setPipeLining(true)
->setExecuteEagerly(true);
foreach ($data as $customer) {
$request = $curls->createRequest('POST', 'http://some-resource.com')
->header('Authorization', 'Bearer: abc123')
->header('Content-Type', $json->getMimeType())
->body($json->encode($customer))
->on('complete', function($response) {
var_dump($response);
});
$multi->add($request);
}
$multi->complete();