nandanprac/buzz-bundle
Composer 安装命令:
composer require nandanprac/buzz-bundle
包简介
Symfony Bundle for using the lightweight Buzz HTTP client.
关键字:
README 文档
README
Symfony Bundle for using the lightweight Buzz HTTP client.
Installation
Add the bundle in your composer.json file:
{ "require": { "gremo/buzz-bundle": "~1.0" } }
Then run composer update and register the bundle with your kernel in app/appKernel.php:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Gremo\BuzzBundle\GremoBuzzBundle(), // ... ); }
Legacy Symfony (2.0.*)
Add the following to your deps file:
[buzz]
git=https://github.com/kriswallsmith/Buzz.git
[GremoBuzzBundle]
git=https://github.com/gremo/GremoBuzzBundle.git
target=bundles/Gremo/BuzzBundle
Then run php bin/vendors update and register the namespaces with the autoloader (app/autoload.php):
<?php // app/autoload.php $loader->registerNamespaces(array( // ... 'Buzz' => __DIR__.'/../vendor/buzz/lib', 'Gremo' => __DIR__.'/../vendor/bundles', // ... ));
Finally register the bundle with your kernel in app/appKernel.php:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Gremo\BuzzBundle\GremoBuzzBundle(), // ... ); }
Configuration
Configuration is not needed. Available options and types (for the default values see Buzz\Client\AbstractClient):
# GremoBuzzBundle Configuration gremo_buzz: client: "native" # allowed "curl", "multi_curl" or "native" options: ignore_errors: ~ # boolean max_redirects: ~ # integer proxy: ~ # string timeout: ~ # integer verify_host: ~ # integer verify_peer: ~ # boolean
Usage
Get the gremo_buzz service from the service container:
/** @var $browser \Buzz\Browser */ $browser = $this->get('gremo_buzz');
Refer to Kris Wallsmith Buzz library for sending HTTP requests.
Dependency Injection Tags
You can register a listener creating a service that implements Buzz\Listener\ListenerInterface and tagging it as gremo_buzz.listener (optionally defining a priority attribute). Higher priority means that the corresponding listener is executed first.
Example listener that logs outgoing requests:
<?php use Buzz\Listener\ListenerInterface; use Buzz\Message\MessageInterface; use Buzz\Message\RequestInterface; use JMS\DiExtraBundle\Annotation as DI; use Psr\Log\LoggerInterface; /** * @DI\Service("buzz.listener.logger") * @DI\Tag("gremo_buzz.listener", attributes={"priority"=10}) */ class BuzzLoggerListener implements ListenerInterface { /** * @var \Psr\Log\LoggerInterface */ private $logger; /** * @var float */ private $startTime; /** * @DI\InjectParams({"logger" = @DI\Inject("logger")}) */ public function __construct(LoggerInterface $logger) { $this->logger = $logger; } /** * {@inheritdoc} */ public function preSend(RequestInterface $request) { $this->startTime = microtime(true); } /** * {@inheritdoc} */ public function postSend(RequestInterface $request, MessageInterface $response) { $this->logger->info(sprintf( 'Sent "%s %s%s" in %dms', $request->getMethod(), $request->getHost(), $request->getResource(), round((microtime(true) - $this->startTime) * 1000) )); } }
Note that this example uses the new Psr\Log\LoggerInterface and may not work for old versions of Symfony.
nandanprac/buzz-bundle 适用场景与选型建议
nandanprac/buzz-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http client」 「buzz」 「gremo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nandanprac/buzz-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nandanprac/buzz-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nandanprac/buzz-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Debug application using Pinkfire
Buzz plugin to manage WSSE authentication
Silex ServiceProvider for Buzz Http Library
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-04