定制 aratech/kontentai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aratech/kontentai

最新稳定版本:v0.9.56

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.

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-31