承接 netglue/prismic-cli 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

netglue/prismic-cli

Composer 安装命令:

composer require netglue/prismic-cli

包简介

CLI tooling for developing Prismic content models

README 文档

README

Build Status

codecov Psalm Type Coverage

Latest Stable Version Total Downloads

This is a development tool based on Symfony Console so require it with --dev - it's meant to be used as part of a build process with a tool like npm-watch or similar.

$ composer require --dev netglue/prismic-cli

The primary installation target for this lib is a Mezzio app as it has been built to integrate with the Laminas CLI package.

During installation you should be prompted to inject the config provider(s) if installing as part of a Mezzio app.

laminas/laminas-cli is not required by this lib, so you'll need to require it too if that's what you want.

There's nothing to stop you from using this tool 'stand-alone' - the ./example/example.php should point you in the right direction for this. It's also worth inspecting that example so everything makes sense.

Building Document Model JSON Files

The command primo:build, given some configuration, generates JSON files from PHP sources that you can copy and paste into Prismic.io's custom type editor.

Assuming that you are using a DI container that returns application-wide config as an array using config as a service id, You can drop configuration similar to this in order to have the tool build your types upon invocation.

<?php
return [
    'primo' => [
        'cli' => [
            'builder' => [
                'source' => __DIR__ . '/../directory/where/plain-php-files-are',
                'dist' => __DIR__ . '/../where-you-want-the-json-files-to-go',
            ],
        ],
        'types' => [
            [
                'id' => 'some-type',
                'name' => 'My Document Type',
                'repeatable' => true,
            ],
        ],
    ],
];

The lib currently lacks documentation and a decent test suite but there is an annotated example in ./example. When it comes to configuring as part of a Mezzio app, please examine ./src/ConfigProvider.php for more information.

Upload, Download and Diff Document Models Against the Remote Repository

If you have setup the "Custom Types API" and have a valid access token to use it, adding the following to your configuration along with the contents of CustomTypeApiConfigProvider will configure 3 additional commands that will enable you to upload, download and diff changes between your local and remote definitions:

<?php
// Local Configuration
return [
    'primo' => [

        // ...

        'custom-type-api' => [
            'token' => 'an access token retrieved from repository settings',
            'repository' => 'my-repo', // The repo name such as "my-repo" as opposed to the full url or "my-repo.prismic.io"
        ],

        // ...
    ],
];

Once configured, you can issue

  • primo:types:download to download all JSON definitions to your local dist directory, or add a type argument to download just one of them.
  • primo:types:upload to upload locally defined definitions to the remote types api make them immediately available in your repository. Again, a type argument will process a single definition.
  • primo:types:diff will produce colourised diffs in your console showing the changes between local and remote.

These tools make use of netglue/prismic-doctype-client, so check that out if you'd like some more information, also link to the Prismic Custom Types API Docs.

Commands that Query a Repository

Theres also some commands for getting information from a repository. These commands are opt-in. During installation there's a config provider called ApiToolsConfigProvider which you can skip if you don't want these tools available.

All of the commands require a configured Api Client, using netglue/prismic-client.

The above mentioned config provider sets up its own factory for the api client, skipping a cache implementation as it's likely that if you are using the tools, you don't want stale information.

Configure the repository somewhere with information similar to:

return [
    'prismic' => [
        'api' => 'https://your-repo.cdn.prismic.io/api/v2',
        'token' => null, // Or 'string-access-token'
    ],
];

Currently Available Commands

  • primo:info - Without arguments, provides information about the repository itself
  • primo:info <document-id> - Shows information about a specific document
  • primo:list - Lists the types available in the configured repository
  • primo:list <type> - Lists documents and id's of a specific type

You can try out these commands on the test repo used for the Prismic/Mezzio integration lib we wrote at netglue/primo by running ./example/api-queries.php

Note: This lib is not a replacement for JS cli tooling provided by Prismic…

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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