Installing CRUD view requires only a few steps
The recommended installation method for this plugin is by using composer.
In your aplication forlder execute:
composer require friendsofcake/crud-view
It is highly recommended that you install the Search
plugin as well:
composer require friendsofcake/search
Execute the following lines from your application folder:
bin/cake plugin load Crud
bin/cake plugin load CrudView
bin/cake plugin load BootstrapUI
bin/cake plugin load Search
I you haven’t configured the CRUD plugin already add the following line to your
src/Controller/AppController.php
file
<?php
namespace App\Controller;
class AppController extends \Cake\Controller\Controller {
use \Crud\Controller\ControllerTrait;
public function initialize()
{
$this->viewClass = 'CrudView\View\CrudView';
$this->loadComponent('Crud.Crud', [
'actions' => [
'Crud.Index',
'Crud.View',
'Crud.Add',
'Crud.Edit',
'Crud.Delete',
'Crud.Lookup',
],
'listeners' => [
'CrudView.View',
'Crud.Redirect',
'Crud.RelatedModels',
'CrudView.Search'
]
]);
}
}
If you are familair with the CRUD plugin already, you will immediately understand that Crud view is simply a listener for the events generated by the plugin. If this is new to you, don’t worry, it will be explained in the following sections.
Any controller inheriting from AppController
will automatically implement
the specified actions loaded int the CRUD
component configuration.
Therefore, you can just leave your controller code empty!
<?php
namespace App\Controller;
class CategoriesController extends AppController {
// No code here, but we have all actions available to use!
}
You can now access your categories list by pointing your browser to
http://example.com/categories
. Browse around your new Admin interface for
each of the controllers you have in your application.