nst/craft-publisher
Composer 安装命令:
composer require nst/craft-publisher
包简介
Publisher X enables you to publish saved Drafts on a future date without the need to handle the cache expiration logic. The cronjob handles the publication and the cache invalidation.
README 文档
README
Publisher X enables you to publish saved Drafts on a future date. The cron job handles the publication, and cache invalidation is managed through Craft CMS's native element save events.
It also handles entries that are set to expire or go live in the future, and will trigger cache invalidation through Craft's standard element lifecycle events.
Requirements
- Craft CMS 5.0+
- PHP 8.2+
Installation
composer require teamnovu/craft-publisher
Then install the plugin in the Craft control panel under Settings → Plugins.
Permissions
To publish a draft, the user needs the Save entries permission on the entry's section.
Setup
Create a cron job that runs every minute. You can invoke Publisher X via CLI or HTTP:
CLI (recommended):
* * * * * [PATH_TO_CRAFT]/craft publisher-x/publish
Web:
* * * * * /usr/bin/curl --silent --compressed {siteUrl}/actions/publisher-x/api/publish
Usage with cache plugins
If you use a full-page cache plugin such as Blitz, make sure you also run the queue and refresh expired caches:
* * * * * [PATH_TO_CRAFT]/craft blitz/cache/refresh-expired * * * * * [PATH_TO_CRAFT]/craft queue/run
Events
EVENT_AFTER_PUBLISH_ENTRY
Fired by the Entries service after each successful scheduled publication. Use it to trigger server-side cache purges or any other side-effect tied to publication.
Event::on( Entries::class, Entries::EVENT_AFTER_PUBLISH_ENTRY, function (EntryPublishedEvent $event) { $entry = $event->entry; // canonical entry that was published $draft = $event->draft; // draft that was applied, or null for non-draft schedules $schedule = $event->entryPublish; // the EntryPublish schedule record // trigger your cache purge here } );
The event is only fired when publication succeeds. If the scheduled entry or draft cannot be found (e.g. the entry was deleted), the orphaned record is cleaned up and the event is not fired.
nst/craft-publisher 适用场景与选型建议
nst/craft-publisher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 760 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nst/craft-publisher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nst/craft-publisher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 760
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 48
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-22
