gregnuj / fondant
Fondant 是 CakePHP 3 的插件
dev-master
2019-03-15 08:38 UTC
Requires
- php: >=5.6.0
- cakephp/cakephp: ^3.6.0
- cakephp/plugin-installer: ^1.0
- foxy/foxy: ^1.0.0
- wyrihaximus/twig-view: ^4.3.4
Requires (Dev)
- cakephp/cakephp-codesniffer: ^3.0
- phpunit/phpunit: ^5.7.14|^6.0
This package is not auto-updated.
Last update: 2024-09-19 10:54:00 UTC
README
Scaffolding 和模板为 CakePHP。Fondant 试图改进 CakePHP 的默认模板,通过在 bake 模板中集成更多 JavaScript 来减少定制,从而提高用户体验。
要求
- CakePHP 3.6.0 或更高版本。
- PHP 5.6 或更高版本
先决条件
为 CakePHP 应用程序启用 JSON 资源路由。
使用 composer 安装 foxy
composer require foxy/foxy": "^1.0.0"
安装
composer require gregnuj/fondant:*
或者将此包添加到项目的 composer.json
"require": {
"gregnuj/fondant": "*"
}
现在,在 bootstrap.php
中启用插件(排除 bootstrap 和路由)
Plugin::load('gregnuj/Fondant', ['bootstrap' => false, 'routes' => false]);
您还需要创建资产链接
这就完成了!现在您可以使用 Fondant 了!
文档
Fondant 提供了用于一起使用的自定义组件和模板。模板的主要区别在于使用 Jquery datatables,FondantComponent 提供了用于 datatables 的 服务器端方法。
使用 Fondant 制作
要使用 Fondant 模板进行烘焙,请像通常那样使用 bake,当烘焙控制器和模板时使用 -t|--template 选项。
cake bake controller MyStuffs -t Fondant
cake bake template MyStuffs -t Fondant
在控制器中使用 FondantComponent
建议的方法是按照上述方法烘焙控制器,并根据需要进行修改。
示例控制器类
<?php
namespace App\Controller;
use App\Controller\AppController;
class AliasesController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadComponent('Fondant.Fondant');
$this->loadComponent('Fondant.JqueryUi');
}
public function select2(){
$this->JqueryUi->select2();
}
public function getAssociations(){
$this->Fondant->getAssociations();
}
public function getAssociatedDetails(){
$this->Fondant->getAssociatedDetails();
}
public function index()
{
$this->Fondant->index();
}
public function view($id = null)
{
$this->Fondant->view($id);
}
public function add()
{
$this->Fondant->add();
}
public function edit($id = null)
{
$this->Fondant->edit($id);
}
public function delete($id = null)
{
$this->Fondant->delete($id);
}
}
您可以使用 FondantComponent 方法并修改控制器方法,但请注意,_serialize
变量用于生成 datatables 消费的 JSON。
在控制器中使用 JqueryUiComponent
JqueryUiComponent 提供支持模板中使用的 jQuery 的服务器端功能。
Select2 方法
- select2 - 在添加/编辑模板中提供下拉列表
- autocomplete - 过滤 select2 输入的列表