aratech/kontentai
Composer 安装命令:
composer require aratech/kontentai
包简介
A lightweight package for wrapping kontentai PHP SDK
README 文档
README
Summary
A simple Wrapper Class to the already existing Delivery Client that is provided by the lovely people at the Kontent.ai team.
Developers
Developed By Ammar Jlies, Jimmy Jradeh.
Installation Process
You must have a Laravel Application before you can install this package. After installing your laravel application you can run:
composer require aratech/kontentai
or adjust your composer.json file:
{
"require": {
"aratech/kontentai": "^0.7.0"
}
}
Create a Kontent-ai Client
Creating a Kontent.ai Client is simple and easy, start by adding your Kontent.ai project key to your .env file, and name it KONTENT_AI_KEY:
KONTENT_AI_KEY = "Put Your Project Key Here"
Now, you can create a Kontent.ai Client and assign it to a variable ($app in the example below):
use Aratech\Kontentai; $app = Kontentai::createClient();
Using our solution for querying
To query an item from your Kontent.ai project just use the -> operator:
$result = $app->about_us;
If you want to query multiple items, you can (almost) treat the querying process as if you are doing a query using the Laravel Query Builder Class:
$app->where("name", "article");
Returned type is a Kontentai Object (the same variable $app).
So, you can chain as many methods as you like on the $app client, and when you're done just use the fetch function to fetch the results:
$results = $app->language('es-ES')->where("name", "article")->fetch();
Returned type here is a Laravel collection conatining all the items that are returned from the query.
One Special use case we can do, is using the fetch method without any chained methods behind it:
$results = $app->fetch();
This will return all the items that are available in your Kontent.ai project.
You can also use the Methods that are already built in the DeliveryClient provided by Kontent-ai and chain them with our provided methods:
$results = $app->language('es-ES')->where("name", "article")->orderAsc('elements.product_name')->limit(10)->fetch();
By default, the chained methods will be cleared after you call the fetch() method, but, you can also clear them manually by calling the clearQuery() method on the app object:
$results = $app->clearQuery();
IF you want to grab an instance of the default Kontent.ai client, you can use the getClient() method:
$client = $app->getClient();
Available Methods
where($key, $value)
find($id)
What's the idea behind this class?
The idea is to provide a way to chain methods on top of each other as if you are using the Laravel built-in Query Builder class.
aratech/kontentai 适用场景与选型建议
aratech/kontentai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aratech/kontentai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aratech/kontentai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 41
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-31