定制 netglue/prismic-client 二次开发

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

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

netglue/prismic-client

Composer 安装命令:

composer require netglue/prismic-client

包简介

PHP API Client for Prismic.io

README 文档

README

Stand With Ukraine

Build Status codecov Psalm Type Coverage Latest Stable Version Total Downloads

This is an unofficial PHP client for the Prismic.io headless CMS. In order to keep things simple, this library only supports version 2 of the api, so you'll have to make sure to specify your repository url in the format https://my-repo.prismic.io/api/v2

There is practically zero backwards compatibility with other prismic clients so this is in no way a drop-in replacement. That said, you should find that much of it remains similar.

Features

  • Uses a PSR-18 HTTP client for communicating with the API, so there is no dependency on a particular client implementation. The library depends on you either manually providing an HTTP client or falls back on HTTPlug Discovery to figure out an already available client.
  • Optional caching. You can choose to cache using an HTTP client that can cache responses for you like this little beauty, or provide a PSR cache pool to the named constructor.
  • Helpful methods in the primary interface to retrieve next/previous paginated result sets or merge all paginated results to a single result set.
  • Predictable and consistent exceptions to help you recover gracefully from error conditions.
  • Iterable and filterable collections to represent Slices, groups and RichText making it trivial to locate particular types of content.
  • Completely separate and replaceable HTML serialisation. In fact, the content objects do not have atHtml() or asText() methods at all. There is a shipped HTML serializer which is invokable, but you might not want to use it all, instead preferring to work with your documents in your view layer directly.
  • Easily implement your own result set and your own document types, replacing the default shipped implementations. Got a 'Case Study' type? Hydrate your documents to YourModel\CaseStudy objects so that you can build a robust content model to use in your views and elsewhere.
  • Much less nullability… All collections guarantee a return type of Prismic\Fragment which you can more easily test for a specific type or for its emptiness.

Limitations

  • Only supports V2 of the api as previously mentioned
  • No support for experiments (A/B Tests) because this feature is out-of-order at Prismic itself, it didn't make sense to implement a feature that can't be used (Sad face) - that said, if A/B tests ever become a reality again in the future, it'll be top of the pile.
  • No caching out-of-the-box (Also see "Features")

Installation

Install with composer: composer require netglue/prismic-client

You will also require a PSR-18 HTTP client implementation, of which there are many, for example:

To use the curl adapter from php-http, issue a composer require php-http/curl-client

Documentation

Docs are a work in progress and are hosted in a public prismic repository (obviously!)

You can view the docs by cloning the library, cd to the source and issue a composer install followed by a composer serve. This will start up PHP's built-in server on http://127.0.0.1:8080 showing the docs.

Samples & Examples

Take a look around in the ./samples directory; that's where you’ll find the document explorer used for rendering the documentation and examples for setting up hydrating result sets, link resolver implementations and other stuff.

It's worth mentioning that the document explorer also supports previews meaning you can add http://127.0.0.1/preview as a preview target in your Prismic repository and preview live changes.

Tests

Once you have the library cloned and dependencies installed, you can run the unit tests. Smoke tests will be skipped by default, but you can run them against your own content repositories by either writing a configuration file in test/config/config.php (You'll find an example in there too) or by setting a couple of environment variables in order to run smoke tests against a single repo:

export PRISMIC_REPO="https://my-repo.prismic.io/api/v2"
export PRISMIC_TOKEN="Some access token or not"
vendor/bin/phpunit

Other Clients

The official kit can be found at prismicio/php-kit.

Another, abandoned fork of the official kit can be found at netglue/prismic-php-kit. The reason for abandoning the fork there was the desire to start from a clean slate and make use of the recent PSRs for HTTP factories and clients, completely separate the HTML serialisation process from the content model and provide more flexible ways of hydrating your content model to objects in your domain (Or not as the case may be!).

License

MIT Licensed.

netglue/prismic-client 适用场景与选型建议

netglue/prismic-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 132.59k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「Prismic」 「psr-7」 「psr-17」 「psr-18」 「prismicio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 netglue/prismic-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 netglue/prismic-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 netglue/prismic-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 132.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 19
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-02