vdhicts/wefact-api-client
Composer 安装命令:
composer require vdhicts/wefact-api-client
包简介
A client for the API of WeFact
README 文档
README
Easy WeFact API client
Requirements
This package requires at least PHP 8.2.
Installation
This package can be used in any PHP project or with any framework.
You can install the package via composer:
composer require vdhicts/wefact-api-client
Usage
This package is just an easy client for using the WeFact API. Please refer to the API documentation for more information about the requests.
Getting started
use Vdhicts\WeFact\WeFact; use Vdhicts\WeFact\WeFactRequest; use Vdhicts\WeFact\Enums\WeFactController; // Initialize the client $client = new WeFact($apiKey); // Perform the request $request = new WeFactRequest(WeFactController::CREDITOR, 'list'); $response = $client->request($request); if ($response->ok()) { $response->json('creditors'); }
Or if you need to provide extra parameters (i.e. for a 'add' request):
$request = new WeFactRequest(WeFactController::CREDITOR, 'add', [ 'CompanyName' => 'Vdhicts', ]); $response = $client->request($request);
Extending the client
You can extend the client and implement your own endpoints:
use Vdhicts\WeFact\Enums\WeFactController; use Vdhicts\WeFact\WeFact; use Vdhicts\WeFact\WeFactRequest; class Debtor extends WeFact { public function show(string $debtorCode): Response { $request = new WeFactRequest(WeFactController::DEBTOR, 'show', [ 'DebtorCode' => $debtorCode, ]); return $this->$request($request); } }
Handling errors
A Response object will always be returned. See Error handling of the Http Client.
if ($response->failed()) { var_dump($response->serverError()); }
Laravel
This package can be easily used in any Laravel application. I would suggest adding your credentials to the .env file
of the project:
WEFACT_API_KEY=apikey
Next create a config file wefact.php in /config:
<?php return [ 'api_key' => env('WEFACT_API_KEY'), ];
Then initialize the client with the API key:
$client = new \Vdhicts\WeFact\WeFact(config('wefact.api_key'));
In the future I might make a Laravel specific package which uses this package.
Contribution
Any contribution is welcome, but it should meet the PSR-12 standard and please create one pull request per feature/bug. In exchange, you will be credited as contributor on this page.
Security
If you discover any security related issues in this or other packages of Vdhicts, please email security@vdhicts.nl instead of using the issue tracker.
Support
This package isn't an official package from WeFact, so they probably won't offer support for it. If you encounter a problem with this client or has a question about it, feel free to open an issue on GitHub.
License
This package is open-sourced software licensed under the MIT license.
vdhicts/wefact-api-client 适用场景与选型建议
vdhicts/wefact-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.14k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「wefact」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vdhicts/wefact-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vdhicts/wefact-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vdhicts/wefact-api-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wefact for Laravel 5.8-10.x
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
WeFact API client library for PHP.
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 3.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-23