pecm / pickling
A REST API Client for PECL and PEAR
Fund package maintenance!
Patreon
Requires
- php: ^8.1
- psr-discovery/http-client-implementations: ^1.2
- psr-discovery/http-factory-implementations: ^1.1
- psr/http-client: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.0
- psr/http-message-implementation: ^1.0
Requires (Dev)
- infection/infection: ^0.28
- nyholm/psr7: ^1.3
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5 || ^11.1
- psr-mock/http-client-implementation: ^1.0
- psy/psysh: ^0.12
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.6
Suggests
- nyholm/psr7: A fast PHP7 implementation of PSR-7
- php-http/socket-client: Socket client for PHP-HTTP
This package is auto-updated.
Last update: 2024-11-05 12:50:31 UTC
README
Pickling is a simple yet powerful client for PHP Extension Community Library and PHP Extension and Application Repository REST APIs.
Installation
At the core, Pickling works out-of-the-box with many HTTP Clients through HTTPlug Discovery.
In other words, it requires at least one package for each of the following implementations:
To add Pickling to composer:
composer require pecm/pickling
A general suggestion for HTTP Client, using kriswallsmith/buzz and nyholm/psr7:
composer require kriswallsmith/buzz nyholm/psr7
Usage
More usage examples beyond the simple ones below can be found on the examples/ folder.
Factory Instantiation
// pecl client with standard options $peclClient = Pickling\Factory::createPecl(); // pear client with standard options $pearClient = Pickling\Factory::createPear();
Customized Instantiation
// pecl client $peclClient = new Pickling\Client( // a class that implements Pickling\Channel\ChannelInterface new Pickling\Channel\Pecl(), // a class that implements Psr\Http\Client\ClientInterface new Http\Client\Socket\Client(), // a class that implements Psr\Http\Message\RequestFactoryInterface new Nyholm\Psr7\Factory\Psr17Factory(), // a class that implements Psr\Http\Message\StreamFactoryInterface new Nyholm\Psr7\Factory\Psr17Factory() ); // pear client $pearClient = new Pickling\Client( // a class that implements Pickling\Channel\ChannelInterface new Pickling\Channel\Pear(), // a class that implements Psr\Http\Client\ClientInterface new Http\Client\Socket\Client(), // a class that implements Psr\Http\Message\RequestFactoryInterface new Nyholm\Psr7\Factory\Psr17Factory(), // a class that implements Psr\Http\Message\StreamFactoryInterface new Nyholm\Psr7\Factory\Psr17Factory() );
Client
Get Package List
$peclClient->getPackageList(); Pickling\Resource\PackageList Object ( [channel:Pickling\Resource\PackageList:private] => "pecl.php.net" [list:Pickling\Resource\PackageList:private] => Array ( [0] => "ahocorasick" // ... [408] => "zstd" ) )
Package
Get Package Release List
$peclClient->with('amqp')->getReleaseList(); Pickling\Resource\Package\ReleaseList Object ( [packageName:Pickling\Resource\Package\ReleaseList:private] => "amqp" [channel:Pickling\Resource\Package\ReleaseList:private] => "pecl.php.net" [list:Pickling\Resource\Package\ReleaseList:private] => Array ( [0] => Pickling\Resource\Package\Release\Version Object ( [number:Pickling\Resource\Package\Release\Version:private] => "1.10.2" [stability:Pickling\Resource\Package\Release\Version:private] => "stable" ) // ... [41] => Pickling\Resource\Package\Release\Version Object ( [number:Pickling\Resource\Package\Release\Version:private] => "0.1.0" [stability:Pickling\Resource\Package\Release\Version:private] => "beta" ) ) )
Get Package Latest Release
$peclClient->with('amqp')->getLatestVersion(); "1.10.2"
Get Package Info
$peclClient->with('amqp')->getInfo(); Pickling\Resource\Package\Info Object ( [packageName:Pickling\Resource\Package\Info:private] => "amqp" [channel:Pickling\Resource\Package\Info:private] => "pecl.php.net" [category:Pickling\Resource\Package\Info:private] => "Networking" [license:Pickling\Resource\Package\Info:private] => "PHP License" [licenseUri:Pickling\Resource\Package\Info:private] => "" [summary:Pickling\Resource\Package\Info:private] => "Communicate with any AMQP compliant server" [description:Pickling\Resource\Package\Info:private] => "This extension can communicate with any AMQP spec 0-9-1 compatible server, such as RabbitMQ, OpenAMQP and Qpid, giving you the ability to create and delete exchanges and queues, as well as publish to any exchange and consume from any queue." [packageReleasesLocation:Pickling\Resource\Package\Info:private] => "" [parentPackage:Pickling\Resource\Package\Info:private] => "" [packageReplaceBy:Pickling\Resource\Package\Info:private] => "" [channelReplaceBy:Pickling\Resource\Package\Info:private] => "" )
Package Release
Get Release Info
$peclClient->with('amqp')->at('1.10.2')->getInfo(); Pickling\Resource\Package\Release\Info Object ( [packageName:Pickling\Resource\Package\Release\Info:private] => "amqp" [channel:Pickling\Resource\Package\Release\Info:private] => "pecl.php.net" [version:Pickling\Resource\Package\Release\Info:private] => "1.10.2" [stability:Pickling\Resource\Package\Release\Info:private] => "stable" [license:Pickling\Resource\Package\Release\Info:private] => "PHP License" [releasingMaintainer:Pickling\Resource\Package\Release\Info:private] => "lstrojny" [summary:Pickling\Resource\Package\Release\Info:private] => "Communicate with any AMQP compliant server" [description:Pickling\Resource\Package\Release\Info:private] => "This extension can communicate with any AMQP spec 0-9-1 compatible server, such as RabbitMQ, OpenAMQP and Qpid, giving you the ability to create and delete exchanges and queues, as well as publish to any exchange and consume from any queue." [releaseDate:Pickling\Resource\Package\Release\Info:private] => "2020-04-05 15:41:28" [releaseNotes:Pickling\Resource\Package\Release\Info:private] => "- Windows build: avoid variable lengths arrays (Christoph M. Becker) (https://github.com/pdezwart/php-amqp/issues/368) For a complete list of changes see: https://github.com/pdezwart/php-amqp/compare/v1.10.1...v1.10.2" [releaseSize:Pickling\Resource\Package\Release\Info:private] => 107350 [downloadUri:Pickling\Resource\Package\Release\Info:private] => "https://pecl.php.net/get/amqp-1.10.2" [packageLink:Pickling\Resource\Package\Release\Info:private] => "" )
License
This library is licensed under the MIT License.