graft/framework-core
Composer 安装命令:
composer require graft/framework-core
包简介
Framework Core for WordPress Plugin Development.
README 文档
README
Graft is an little Framework for WordPress Plugins development. It give you clean code architecture for OOP and MVC pattern in your Plugin.
Why Graft ?
For OOP
I am an developer who love OOP, so when i began WordPress Development i was frustrated that some Plugins don't use OOP.
Of course, I understand that some little Plugins don't have to use OOP, so this Framework is destinated for big Plugins with complex features.
Make more Developer Friendly Plugins
During my experience of WordPress Developer, when i was using some Plugin i often asked sames questions :
- Which Hooks uses this Plugin ?
- Is this Plugin give some availables Filters ?
- Is it possible to override this Plugin's Templates ?
Main Graft Features
OOP
In an WordPress Plugin you do not have to make OOP Code (you can use only functions) But with Graft, all things is only Object for better code quality.
MVC Pattern and Template Overriding from Theme
Graft use the Twig Template Engine to allow you to doing MVC Pattern in your Plugin. And Graft allow developers to override all Plugin's Template from their Theme (if you give permission)
Annotations
In Graft, due to the OOP, all basics WordPress functions like add_action('wp_head') or add_filter() are Annotations like @Action(name="wp_head"), so you don't have to specify any callback, it use the specified Method.
Container
All Plugins made with Graft have an Dependency Injection Container (PHP-DI Container) for using autowiring with your Classes or with Graft Injectable Components.
And the container have the list of all WordPress Components used by the Plugin (Action, Filter, Admin Page ...)
Example
This is code example with Graft Framework
use Graft\Framework\Annotation\Filter; //use Filter Annotation use Graft\Framework\Injectable\Renderer; /** * Class that will be construct by the Factory * This class can be injected with autowiring in other Class. */ class MyHookManager { /** * HookManager Renderer * Use for Template Rendering * * @var Renderer */ private $renderer; /** * MyHookManager Constructor * using autowiring for dependency injection * * @param Renderer $renderer */ public function __construct(Renderer $renderer) { $this->renderer = $renderer; } /** * This Method will be add to 'the_title' Filter by Annotation * * And 'the_title' Filter will be added in the Plugin Container * for other developers who want to know wich Hooks this Plugin using. * * @Filter(name="the_title") * * @param string $title Current Title * * @return string */ public function titleFilterHook(string $title) { //some example code... $title = trim($title); // using Twig for Custom Title HTML... // this template can be override in the Theme in // (wp-content/themes/mytheme/currentPluginName/filter/title.html.twig) for example. return $this->renderer->render('filter/title.html.twig', ['title' => $title]); } }
graft/framework-core 适用场景与选型建议
graft/framework-core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 107 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 graft/framework-core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 graft/framework-core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 107
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-14