codeat3/foaas-client
Composer 安装命令:
composer require codeat3/foaas-client
包简介
A PHP client for FOAAS service
关键字:
README 文档
README
A PHP Client of FOAAS
Installation
You can install the package via composer:
composer require codeat3/foaas-client
Usage
Basic usage of the client
use Codeat3\FoaasClient\FoaasClient; $foaasClient = new FoaasClient([ 'decency' => 'low', // possible decency filter options are 'low', 'medium', 'high', 'extreme' - default is no filter ]); echo $foaasClient->what('John')->get(); // Output What the f*ck‽ - John
Using format to get the response as per your need
use Codeat3\FoaasClient\FoaasClient; $foaasClient = new FoaasClient([ 'decency' => 'low', 'responseAs' => 'array', // possible response formats are 'text' (default), 'html', 'xml', 'json', 'array' ]); print_r($foaasClient->what('John')->get()); // Output Array ( [message] => What the f*ck‽ [subtitle] => - John )
Also few helpers are provided for the type of output expected
$foaasClient = new FoaasClient([ 'decency' => 'low', ]); echo $foaasClient->what('John')->getAsText(); // What the f*ck‽ - John echo $foaasClient->what('John')->getAsXml(); // <?xml version="1.0" encoding="UTF-8"?> <foaas:response xmlns:foaas="http://foaas.com/f*ckoff"> <foaas:message>What the f*ck‽</foaas:message> <foaas:subtitle>- John</foaas:subtitle> </foaas:response> echo $foaasClient->what('John')->getAsHtml(); // <!DOCTYPE html> <html> <head> <title>FOAAS - What the f*ck‽ - John</title> <meta charset="utf-8"> <meta property="og:title" content="What the f*ck‽ - John"> ... echo $foaasClient->what('John')->getAsJson(); // {"message":"What the f*ck‽","subtitle":"- John"} print_r($foaasClient->what('John')->getAsArray()); /* Array ( [message] => What the f*ck‽ [subtitle] => - John ) */
Custom Responses
You can implement the custom responses and pass it in customer as per your need
// Implementation class ObjectResponse implements FoaasResponse { protected $acceptHeader = 'application/json'; public function getHeaders():string { return $this->acceptHeader; } public function response(string $response, FoaasFilter $filter) { $response = $filter->filter($response); return json_decode($response); } } // Use $foaasClient = new FoaasClient([ 'decency' => 'low', 'responseAs' => 'object', 'responseFormats' => [ 'object' => ObjectResponse::class, ] ]); var_dump($foaasClient->what('John')->get()); /* class stdClass#27 (2) { public $message => string(16) "What the f*ck‽" public $subtitle => string(6) "- John" } */
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email swapnilsarwe@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
PHP Package Boilerplate
This package was generated using the PHP Package Boilerplate.
codeat3/foaas-client 适用场景与选型建议
codeat3/foaas-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「codeat3」 「foaas-client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codeat3/foaas-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codeat3/foaas-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codeat3/foaas-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-17