承接 three-mammals/pushy 相关项目开发

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

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

three-mammals/pushy

Composer 安装命令:

composer require three-mammals/pushy

包简介

A plugin to make Wordpress headless.

README 文档

README

What is it?

Pushy is an open source Wordpress plugin that pushes data out of wordpress in the form of events. This enables using Wordpress as a headless CMS. That is rather than user requests for content hitting Wordpress for rendering etc you can create your own UI using whatever technology you want.

This pattern is proving somewhat popular for legacy systems like Wordpress and Magento. These systems provide amazing features but their API offerings are difficult to use if you wanted to use something like React (Native) & GraphQL.

This pattern is also useful if you need to scale beyond what Wordpress is capable of and have an optimised read model.

This is basically meant to be souped up webhooks.

Latest Stable Version Total Downloads License

Why?

My work want to make Wordpress headless but we don't really have time to work on it. I thought it was an interesting idea so started this to see how it might work in terms of pushing data out.

I am not a PHP developer really so please forgive anything that sucks.

What can I push the messages to?

At the moment you can push the messages to disk using the FilePublisher and AWS SNS using the SNSPublisher. The FilePublisher is only meant to be used for manual testing and messing around.

After you install Pushy as a wordpress plugin you will get a section added under options called Pushy Options. Under this you can set if you want to use the FilePublisher or SNSPublisher. The location is either the root path where you want the FilePublisher to write the messages e.g. /var/www/html/data/ or the SNS topic arn prefix e.g. arn:aws:sns:eu-west-1:940731442544:. This is because Pushy will publish an event with a name to this location e.g. SNS it will publish to arn:aws:sns:eu-west-1:940731442544:PostUpdated when a post is updated or to /var/www/html/data/PostUpdated-35c48bc8-348d-11e9-8e72-0242ac120003.json using the FilePublisher. Note the guid here is just the messages id for uniqueness.

What events are published?

  • action save_post post_type post and post_status publish publishes PostUpdated event
  • action save_post post_type post and post_status private publishes PostUpdated event
  • action save_post post_type post and post_status trash publishes PostTrashed event
  • action save_post post_type revision publishes Revision event
  • action save_post post_type post and post_status draft publishes PostDraft event
  • action save_post post_type post and post_status auto-draft publishes PostDraft event
  • action save_post post_type page and post_status auto-draft publishes PageDraft event
  • action save_post post_type page and post_status draft publishes PageDraft event
  • action save_post post_type page and post_status publish publishes PageUpdated event
  • action save_post post_type nav_menu_item and post_status publish publishes MenuItemPublished event
  • action save_post post_type post and post_status future publishes FuturePostUpdated event
  • action save_post post_type page and post_status future publishes FuturePageUpdated event
  • action untrash_post publishes PostRestored event
  • action delete_post publishes PostDeleted event
  • action edit_category, delete_category, create_category publishes CategoriesUpdated event
  • action wp_update_nav_menu publishes MenuUpdated event
  • action wp_delete_nav_menu publishes MenuDeleted event
  • filter wp_handle_upload_prefilter publishes MediaUploaded event
  • action add_attachment publishes AttachmentUploaded event
  • action delete_attachment publishes AttachmentDeleted event
  • action update_attachment publishes AttachmentUpdated event
  • action publish_page publishes PagePublished event
  • action updated_postmeta publishes PostMetaUpdated event
  • action edit_post_tag, delete_post_tag, create_post_tag publishes TagsUpdated event

These events all contain the data serialised as json that is passed into the hook by Wordpress. Some of them make additonal data fetches.

Terraform

AWS

I have setup a simple terraform script to deploy the required SNS topics. A good knowledge of terraform is required to use this because you will probably want to make changes. I have the credentials setup in a normal way locally for AWS cli and I have some helper scripts to execute terraform in from docker.

The AWS terraform provider is set up in a very simple way and you might want to change this :)

From root call ./infrastructure/terraform/aws/plan.sh to create a plan. From root call ./infrastructure/terraform/aws/apply.sh to apply the plan and create the resources in AWS. From root call ./infrastructure/terraform/aws/apply.sh to destroy created resources.

Whats next?

Generally make everything better. At the moment not all hooks that are relavent are supported. Maybe we should fetch more data when doing say PostUpdated? Can we be more accurate with save PostCreated rather than just PostUpdated etc. Can we target specific post types better. Can we do better with media?

List of actions we can use here

How do I run the tests

I do ./vendor/bin/phpunit --bootstrap tests/autoload.php tests/

Useful composer stuff I forget

php composer.phar require package-name php composer.phar install

three-mammals/pushy 适用场景与选型建议

three-mammals/pushy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 15, 最近一次更新时间为 2019 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 three-mammals/pushy 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-25