Cakephp: Problem creating basic plugin using CakePHP 3 Documentation

Created on 17 May 2015  路  1Comment  路  Source: cakephp/cakephp

I just installed CakePHP 3 for the first time (long time 1.3 user - decided it was time to finally update).

Using the basic installation instructions, these are the commands I used:

Created a composer.json file:

{
    "require": {
        "cakephp/cakephp": "~3.0"
    }
}

Ran the command:

composer create-project --prefer-dist cakephp/app app

So far so good, I can get to my app through the browser, and everything is configured properly (except the database yet obviously).

Now I create a plugin by following the instructions from this page: http://book.cakephp.org/3.0/en/plugins.html#creating-a-plugin-using-bake

bin/cake bake plugin ContactManager

Looks like everything was created just fine.

Then I create the controller with:

bin/cake bake controller --plugin ContactManager Contacts

Again, all the files look in place.

However, when I try to access the files from:

http://example.com/contact_manager/contacts/index

I get a Missing Controller error file that tells me:

Error: Create the class ContactsController below in file:
/path/to/example.com/app/plugins/ContactManager/src/Controller/ContactsController.php

But that file already exists, it was created by bake and it looks complete.

This is the error that appear in the log file:

2015-05-16 23:33:49 Error: [Cake\Routing\Exception\MissingControllerException] Controller class
Contacts could not be found.
Exception Attributes: array (
  'class' => 'Contacts',
  'plugin' => 'ContactManager',
  'prefix' => NULL,
  '_ext' => NULL,
)
Request URL: /contact_manager/contacts
Stack Trace:
#0 /path/to/example.com/app/webroot/index.php(37): Cake\Routing\Dispatcher-    >dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#1 {main}

Again, I stress that at this point, I've not modified anything by hand, literally just running the 3 commands: composer, bake plugin, bake plugin controller, and then try to access via browser.

I've tried baking multiple times, different controllers / plugin names and I've tried creating the files by hand. I've wiped the folder multiple times and tried starting all over again from scratch. Nothing that I can do seems to be registering. Each time I'm met with the same confusing error.

When I bake a controller NOT inside a plugin and test it, everything works fine and it starts to tell me about missing models and views (as expected).

But inside a plugin, I can't even get cake to acknowledge that the controller file exists.

Most helpful comment

Nevermind, I believe I was having an issue that resolved with:

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

>All comments

Nevermind, I believe I was having an issue that resolved with:

Plugin::load('ContactManager', ['autoload' => true, 'bootstrap' => false, 'routes' => true]);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Erwane picture Erwane  路  3Comments

josbeir picture josbeir  路  3Comments

lorenzo picture lorenzo  路  4Comments

cleptric picture cleptric  路  3Comments

saeideng picture saeideng  路  3Comments