sweetchuck / pear-client
Rest client for Pecl/Pear servers
1.x-dev
2023-12-26 12:55 UTC
Requires
- php: >=7.4
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- cache/array-adapter: ^1.0
- guzzlehttp/guzzle: ^7.0
- league/openapi-psr7-validator: ^0.15
Requires (Dev)
- codeception/codeception: ^4.0
- codeception/module-asserts: ^1.1
- nuvoleweb/robo-config: ^2.0
- squizlabs/php_codesniffer: ^3.5
- sweetchuck/codeception-module-robo-task-runner: 2.x-dev
- sweetchuck/git-hooks: 2.x-dev
- sweetchuck/robo-git: 2.x-dev
- sweetchuck/robo-phpcs: 2.x-dev
- sweetchuck/robo-phpmd: 2.x-dev
- sweetchuck/utils: 1.x-dev
- symfony/error-handler: ^5.0 || ^6.0
This package is auto-updated.
Last update: 2024-10-26 14:53:16 UTC
README
PEAR channel server REST interface
Usage
<?php use GuzzleHttp\MessageFormatter; use Psr\Log\LogLevel; use Sweetchuck\PearClient\PearClient; use Symfony\Component\Console\Logger\ConsoleLogger; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; require_once './vendor/autoload.php'; $logOutput = new ConsoleOutput(); $logVerbosity = [ LogLevel::EMERGENCY => OutputInterface::VERBOSITY_QUIET, LogLevel::ALERT => OutputInterface::VERBOSITY_QUIET, LogLevel::CRITICAL => OutputInterface::VERBOSITY_QUIET, LogLevel::ERROR => OutputInterface::VERBOSITY_QUIET, LogLevel::WARNING => OutputInterface::VERBOSITY_QUIET, LogLevel::NOTICE => OutputInterface::VERBOSITY_QUIET, LogLevel::INFO => OutputInterface::VERBOSITY_QUIET, LogLevel::DEBUG => OutputInterface::VERBOSITY_QUIET, ]; $logger = new ConsoleLogger($logOutput, $logVerbosity); $logMessageFormatter = new MessageFormatter(); $options = [ 'base_uri' => 'https://pecl.php.net/rest/', 'handler' => PearClient::createHttpClientHandlerStack( null, $logger, $logMessageFormatter, ), ]; $pecl = new PearClient(PearClient::createHttpClient($options)); $categories = $pecl->categoriesGet(); foreach ($categories->list as $category) { echo "name: {$category->name}", PHP_EOL; echo "href: {$category->href}", PHP_EOL; $packages = $pecl->categoryPackagesGet($category->name); foreach ($packages->list as $package) { echo "name: {$package->name}", PHP_EOL; echo "description: {$category->description}", PHP_EOL; break; } break; }