pickling é um cliente simples, mas poderoso, para PHP Extension Community Library e APIs REST de extensão PHP e repositório de aplicativos.
Basicamente, pickling funciona imediatamente com muitos clientes HTTP por meio do HTTPlug Discovery.
Em outras palavras, requer pelo menos um pacote para cada uma das seguintes implementações:
Para adicionar pickling ao compositor:
composer require pecm/ pickling
Uma sugestão geral para cliente HTTP, usando kriswallsmith/buzz e nyholm/psr7:
composer require kriswallsmith/buzz nyholm/psr7
Mais exemplos de uso além dos simples abaixo podem ser encontrados na pasta exemplos/.
Instanciação de fábrica
// pecl client with standard options
$ peclClient = pickling Factory:: createPecl ();
// pear client with standard options
$ pearClient = pickling Factory:: createPear ();
Instanciação personalizada
// pecl client
$ peclClient = new pickling Client (
// a class that implements pickling ChannelChannelInterface
new pickling Channel Pecl (),
// a class that implements PsrHttpClientClientInterface
new Http Client Socket Client (),
// a class that implements PsrHttpMessageRequestFactoryInterface
new Nyholm Psr7 Factory Psr17Factory (),
// a class that implements PsrHttpMessageStreamFactoryInterface
new Nyholm Psr7 Factory Psr17Factory ()
);
// pear client
$ pearClient = new pickling Client (
// a class that implements pickling ChannelChannelInterface
new pickling Channel Pear (),
// a class that implements PsrHttpClientClientInterface
new Http Client Socket Client (),
// a class that implements PsrHttpMessageRequestFactoryInterface
new Nyholm Psr7 Factory Psr17Factory (),
// a class that implements PsrHttpMessageStreamFactoryInterface
new Nyholm Psr7 Factory Psr17Factory ()
);
Obter lista de pacotes
$ peclClient -> getPackageList ();
pickling Resource PackageList Object
(
[channel: pickling Resource PackageList :private] => " pecl.php.net "
[list: pickling Resource PackageList :private] => Array
(
[ 0 ] => " ahocorasick "
// ...
[ 408 ] => " zstd "
)
)
Obtenha lista de lançamento de pacotes
$ 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 "
)
)
)
Obtenha a versão mais recente do pacote
$ peclClient -> with ( ' amqp ' )-> getLatestVersion ();
" 1.10.2 "
Obtenha informações do pacote
$ 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] => ""
)
Obtenha informações de lançamento
$ 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] => ""
)
Esta biblioteca está licenciada sob a licença MIT.