The recommended installation method for this plugin is by using composer.
composer require friendsofcake/crud:^5.0
You can also check Packagist.
The Crud plugin provides a trait which will catch a MissingActionException and then step in to provide scaffold actions to the controllers.
To enable Crud across your whole application add the trait to your src/Controller/AppController.php
namespace App\Controller;
class AppController extends \Cake\Controller\Controller
{
use \Crud\Controller\ControllerTrait;
}
Note
To have Crud just scaffold a single controller you can just add the ControllerTrait
to that specific controller.
Adding the ControllerTrait
itself do not enable anything Crud, but simply installs the code to handle
the \Cake\Error\MissingActionException
exception so you don’t have to implement an action in your controller
for Crud to work.
The next step is to load the Crud component in your controller. A basic example is as follows, and will enable the Crud plugin to scaffold all your controllers index actions.
class AppController extends \Cake\Controller\Controller
{
use \Crud\Controller\ControllerTrait;
public function initialize()
{
parent::initialize();
$this->loadComponent('Crud.Crud', [
'actions' => [
'Crud.Index'
]
]);
// Other application wide controller setup
}
}
Further configuration options are detailed on the configuration page.