Hi,
Anyone can guide me to create new cakephp 3 plugin?
Thanks.
Hi,
Anyone can guide me to create new cakephp 3 plugin?
Thanks.
You can create plugin by specially two way.
Using cakebake
Creating plugin structure
For Cakebake you just need to run this code by you terminal “bin/cake bake plugin YourPluginName”.
It will do lots of work automatic like make the plugin sturcture , activate the plugin by changing on .phar file. In one word you don’t need to do any thing in your coding you just get a ready made plugin for use.
But if you want to make plugin by your own then you have to follow these process.
Make this folder structure outside src.
/src
/plugins
/ContactManager
/config
/src
/Controller
/Component
/Model
/Table
/Entity
/Behavior
/View
/Helper
/Template
/Layout
/tests
/TestCase
/Fixture
/webroot
Change into config/bootstrap.php file
Plugin::load('YourPluginName', ['routes' => true]);
OR
Plugin::loadAll(['routes' => true]);
<?php
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\Router;
Router::plugin(
'YourPluginName',
['path' => '/your-plugin-name'],
function ($routes) {
$routes->fallbacks(DashedRoute::class);
}
);
It’s ready… Now to access this plugin go to this link
// Access the index route of a plugin controller.
/your-plugin-name/contacts
// Any action on a plugin controller.
/your-plugin-name/contacts/view/1
thanks for your reply.