avtocod/b2b-api-php-laravel
Composer 安装命令:
composer require avtocod/b2b-api-php-laravel
包简介
Laravel package for a working with B2B API service
README 文档
README
B2B Api client integration for Laravel applications
Install
Require this package with composer using the following command:
$ composer require avtocod/b2b-api-php-laravel "^4.0"
Installed
composeris required (how to install composer).
You need to fix the major version of package.
After that you should "publish" package configuration file using next command:
$ php ./artisan vendor:publish --provider='Avtocod\B2BApi\Laravel\ServiceProvider'
And modify ./config/b2b-api-client.php.
Usage
This package provides:
- Connections factory (
ConnectionsFactoryInterface) - B2B API client factory (configuration for it loads from published configuration file); - Report types repository (
RepositoryInterface) - single entry-point for getting access to the report types information;
In any part of your application you can resolve their implementations. For example, in artisan command:
<?php declare(strict_types = 1); namespace App\Console\Commands; use Avtocod\B2BApi\Params\UserReportMakeParams; use Avtocod\B2BApi\Laravel\ReportTypes\RepositoryInterface; use Avtocod\B2BApi\Laravel\Connections\ConnectionsFactoryInterface; class SomeCommand extends \Illuminate\Console\Command { /** * The console command name. * * @var string */ protected $name = 'some:command'; /** * Execute the console command. * * @param RepositoryInterface $report_types * @param ConnectionsFactoryInterface $connections * * @return void */ public function handle(RepositoryInterface $report_types, ConnectionsFactoryInterface $connections): void { $uid = $report_types->default()->getUid(); // Get default report type UID // Create a parameter object for a request to make a report $report_make_params = UserReportMakeParams($uid, 'VIN', 'Z94CB41AAGR323020') $report_uid = $connections->default() ->userReportMake($report_make_params) ->first() ->getReportUid(); $this->comment("Report UID: {$report_uid}"); } }
Events
Also this package proxying B2B Api client events into Laravel events dispatcher. So, feel free for writing own listeners like:
<?php declare(strict_types = 1); namespace App\Listeners; use Psr\Log\LoggerInterface; use Psr\Http\Message\ResponseInterface; use Avtocod\B2BApi\Events\RequestFailedEvent; class LogFailedB2bApiRequestListener { /** * @var LoggerInterface */ protected $logger; /** * Create a new listener instance. * * @param LoggerInterface $logger */ public function __construct(LoggerInterface $logger) { $this->logger = $logger; } /** * @param RequestFailedEvent $event * * @return void */ public function handle(RequestFailedEvent $event): void { $this->logger->warning('Request to the Avtocod B2B API Failed', [ 'request_uri' => $event->getRequest()->getUri(), 'response_code' => $event->getResponse() instanceof ResponseInterface ? $event->getResponse()->getStatusCode() : null ]); } }
More information about events listeners can be found here
Testing
For package testing we use phpunit framework and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:
$ make build $ make latest # or 'make lowest' $ make test
Changes log
Changes log can be found here.
Support
If you will find any package errors, please, make an issue in current repository.
License
This is open-sourced software licensed under the MIT License.
avtocod/b2b-api-php-laravel 适用场景与选型建议
avtocod/b2b-api-php-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25.53k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2017 年 10 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「service」 「laravel」 「b2b」 「avtocod」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 avtocod/b2b-api-php-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 avtocod/b2b-api-php-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 avtocod/b2b-api-php-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fast and intuitive dependency injection container.
Registry service.
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
Service auto install for Nette Framework
Structure for the Laravel Service-Repository Pattern
Base Skeleton for Laravel Application
统计信息
- 总下载量: 25.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-14