2
votes

I moved working plugin from /plugins/pluginname directory to /vendor/myname/pluginname

URL on which I call plugin controller is

http://domain.local/pluginname/index

Before moving from first directory to another, plugin was working as expected. I moved plugin to new directory to make it reusable for other cake PHP apps.

Plugin is installed by composer.

Why do I have message

"Error: Controller class Index could not be found.". All controllers from plugin are not visible on app, throws the same error. Error is thrown from line 79 from file \vendor\cakephp\cakephp\src\Routing\Dispatcher.php

In main bootstrap.php file I put this line:

Plugin::load('MyName/PluginName', ['bootstrap' => false, 'routes' => true]);

Why plugin in vendor directory is not working in my case?

cakePHP3_controller_not_found_error

2
If the plugin was installed by Composer, you should not move it. You should explain why you are doing this and why can not you instead manually install the plugin. - Mirko Pagliai

2 Answers

0
votes

If plugin is installed by Composer, do not move it.

Whether it is installed at the plugin or vendor folder is determined by the author of the plugin.

If you need to fully load the Plugin in your bootstrap, simply use

Plugin::load('PluginName', ['bootstrap' => false, 'routes' => true]);

See http://book.cakephp.org/3.0/en/plugins.html#plugin-configuration

It will simply work regardless if Composer places it in vendor or plugins folder.

Most importantly, leave it in the folder that the author intended it to be in.

Lastly, check that your plugin is suitable for CakePHP 3.x

As for the url, you should expect to use /plugin-name/controller/action

See http://book.cakephp.org/3.0/en/plugins.html#plugin-controllers and I quote

If you want to access what we’ve got going thus far, visit /contact-manager/contacts

0
votes

You can try by setting autoload variable true.Add below code in bootstrap.php, clear cache and then check. Plugin::load('PluginName', ['autoload' => true]);