squidex/squidex

Squidex 无头 CMS 客户端 SDK

1.2.1 2024-09-01 16:42 UTC

This package is auto-updated.

Last update: 2024-10-03 06:26:03 UTC


README

Squidex PHP 库提供了从 JavaScript 和 TypeScript 访问 Squidex API 的功能。可以在 Node.js 和浏览器中使用。

需要 PHP 7 或更高版本。

状态

Version Shield Packagist PHP Version

文档

API 参考文档可在此处获得 这里

安装

composer install @squidex/squidex

用法

use Squidex\Client\Configuration;
use Squidex\Client\SquidexClient;

require_once __DIR__ . '/../vendor/autoload.php';

$config = new Configuration();
$config->setClientId('client-id');
$config->setClientSecret('client-secret');
$config->setAppName('my-app');
// $config->setHost('https://your.squidex-deployment');

$client = new SquidexClient($config);

$response = $client->rules()->runRule("rule-id", true);

echo "Received response from Squidex!\n$response\n";

处理错误

当 API 返回非成功状态码(4xx 或 5xx 响应)时,将抛出一个 ApiException 子类。

use Squidex\Client\ApiException;

try {
    $response = $client->rules()->runRule("rule-id", true);
} catch (err) {
  if (ApiException $) {
    echo $e->getMessage();
  }
}

生成配置

要生成配置,您必须执行以下步骤。

  1. 在本地运行 Squidex 版本。
  2. 运行 /api/docs URL 获取 OpenAPI 规范。
  3. 将 OpenAPI 规范复制到此存储库。
  4. 运行生成器
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi.json -g php --template-dir  /local/templates -o /local/ -c /local/openapi-config.yml

版本

要创建新版本,只需创建一个标签。Packagist 将使用此标签来计算版本。

贡献

虽然我们重视对这个 SDK 的开源贡献,但这个库是程序生成的。直接对此库所做的修改需要移动到我们的生成代码中,否则它们将在下一个生成版本中被覆盖。您可以自由地提交一个 PR 作为概念证明,但请注意,我们无法直接合并它。我们建议首先提交一个 issue 与我们讨论!

另一方面,对 README 的贡献总是非常受欢迎!