chemaclass/knob-base
最新稳定版本:1.1.5.2
Composer 安装命令:
composer require chemaclass/knob-base
包简介
Project base to use Knob MVC PHP Framework.
关键字:
README 文档
README
What's this repository?
- Knob-base: project base to use Knob MVC PHP Framework
- This is a PHP MVC Framework to create WordPress templates easier and funnier than ever before.
- Author: José María Valera Reales
Knob-base is the kernel from Knob-mvc
- This is a Framework based on MVC pattern.
- Knob-base should not be focus on any style of the page, but deal with WP and provide models instead.
- Inspired by latest frameworks we have nowadays for web development such Symfony or Laravel.
- Regarding any question about WP kernel: take a look the official WP documentation: WP Codex and WP Reference.
Creating basic controllers and views
HomeController: Controller for all files from WP:- author.php
->getAuthor(): render thebase/author.mustachetemplate - archive.php
->getArchive(): render thebase/search.mustachetemplate - category.php
->getCategory(): render thebase/search.mustachetemplate - home.php
->getHome(): render thebase/home.mustachetemplate - search.php
->getSearch(): render thebase/search.mustachetemplate - single.php
->getSingle($type = 'post'): render thebase/[post|page].mustachetemplate - tag.php
->getTag(): render thebase/search.mustachetemplate - 404.php
->get404(): render thebase/error_404.mustachetemplate
- author.php
Calling a controller from a WordPress template page.
Create a template for WordPress, for example single.php which is used when a Post is loaded.
use Controllers\HomeController; $controller = new HomeController(); $controller->getSingle('post');
Models to get all values from your DB
- You can find all models as Entities from your DB in 'Knob\Models' (src/models/ directory).
For example
Post:
// vendor/chemaclass/knob-base/src/models/Post.php namespace Knob\Models; class Post extends ModelBase { public static $table = "posts"; public function getSlug() { return $this->post_name; } public function getAuthor() { return User::find($this->post_author); } // more sentences... }
- You will be provided with libraries to prepare your
ActionsandFilters(from WordPress). For exampleActions:
// vendor/chemaclass/knob-base/src/libs/Actions.php namespace Knob\Libs; class Actions { public static function setup() { static::adminPrintScripts(); static::adminPrintStyles(); static::loginView(); static::wpBeforeAdminBarRender(); } // rest of the implementation... }
- Also you will be able to create your own widgets as new models.
You have the basics in
Knob\Widgets(src/widgets/ directory). For example PagesWidget:
// vendor/chemaclass/knob-base/src/widgets/PagesWidget.php namespace Knob\Widgets; use Knob\Models\Post; class PagesWidget extends WidgetBase { public function widget($args, $instance) { $instance['pages'] = Post::getPages(); parent::widget($args, $instance); } }
- All of these on the best&easy way ever in
Knob\libs(src/libs/ directory)
Views based on Mustache templates
- All you have to care basically are your templates. That's why we choose Mustache. Is simple, flexible and fun.
Controllers to pull everything together
- From
Knob\Controllers(src/controllers/ directory) - You will be provided a
Knob\Controllers\BaseControllerto extends your own controllers.
// app/controllers/BaseController.php namespace Controllers; use Knob\Controllers\BaseController as KnobBaseController; class BaseController extends KnobBaseController { // more sentences... }
- Then your
HomeControllercould seems like:
// app/controllers/HomeController.php namespace Controllers; use Knob\Controllers\HomeControllerInterface; use Models\Option; class HomeController extends BaseController implements HomeControllerInterface { /** * home.php */ public function getHome() { $args = [ 'posts' => Post::getAll(Option::get('posts_per_page')) ]; return $this->renderPage('base/home', $args); } // rest of the implementation... }
Before the start... you'll need!
Install ruby and compass
- sudo apt-get install ruby
- sudo gem update --system
- sudo apt-get install ruby1.9.1-dev
- sudo gem install compass
- sudo gem install rake
Then, you will be able to compile the scss in the directory of your project:
- /knob-mvc $> rake watch_scss
You'll need a PHP graphics library to be able to use the image editor:
- apt-get install php-imagick php7.0-gd
- service apache2 reload
chemaclass/knob-base 适用场景与选型建议
chemaclass/knob-base 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 166 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 09 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mvc」 「wordpress」 「knob」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chemaclass/knob-base 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chemaclass/knob-base 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chemaclass/knob-base 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
Knob widget for OctoberCMS.
Small extensible framework in PHP
Oauth 2 client for Ubiquity framework
Light, secure and intuitive PHP Framework.
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
统计信息
- 总下载量: 166
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-25