2017 © Pedro Peláez
 

cakephp-plugin fondant

Fondant plugin for CakePHP 3

image

gregnuj/fondant

Fondant plugin for CakePHP 3

  • Wednesday, July 11, 2018
  • by gregnuj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Fondant for CakePHP

Scaffolding and templates for CakePHP. Fondant attempts improve upon the default templates in CakePHP to allow for an improved user experience with less customization by focusing on integrating more Javascript into the bake templates., (*1)

Requirements

  • CakePHP 3.6.0 or greater.
  • PHP 5.6 or greater

Prerequisites

Enable JSON resource routing for your CakePHP application., (*2)

Use composer to intstall foxy:, (*3)

composer require foxy/foxy": "^1.0.0"

Install

composer require gregnuj/fondant:*

or by adding this package to your project's composer.json:, (*4)

"require": {
    "gregnuj/fondant": "*"
}

Now, enable the plugin in your bootstrap.php (exclude bootstrap and routes):, (*5)

Plugin::load('gregnuj/Fondant', ['bootstrap' => false, 'routes' => false]);

You will also need to symlink the assets:, (*6)

|From |To | |--------------------------------------------------------|-------------------------------| TBD, (*7)

That's it! You can now begin using Fondant!, (*8)

Documentation

Fondant supplies custom components and templates meant to be used together. The the primary difference in the templates is the use of Jquery datatables with the FondantComponent supplying server-side methods for datatables., (*9)

Baking with fondant

To bake using the fondant templates use bake as you would normally with the -t|--template option when baking controller and templates., (*10)

cake bake controller MyStuffs -t Fondant
cake bake template MyStuffs -t Fondant

Using FondantComponent in your controllers

The recommended approach is to bake your controllers as described above, and make modifications as needed., (*11)

Example Controller class:, (*12)

<?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);
    }
}

You can use the FondantComponent methods and modify the Controller method as well, but be aware that the _serialize variable is used to generate the JSON for datatables to consume., (*13)

Using JqueryUiComponent in your controllers

The JqueryUiComponent provides server-side function to support jquery used in the templates., (*14)

Select2 methods: * select2 - provides lists for select2 dropdowns in add/edit templates * autocomplete - filters the lists for select2 inputs, (*15)

The Versions

11/07 2018