Skip to content

bake plugin - autoload issues #291

@jzfre

Description

@jzfre

Hello,

I've just tried to create my own plugin as described in official documentation through
bin/cake bake plugin Admin

created "DashboardController" in related directory and when approached
mysite.dev/admin/dashboard

there was an "Missing Controller" Exception, that was saying that my "DashboardController" did not exist.

Docu says:

When using bake for creating a plugin or when installing a plugin using Composer, you don’t typically need to make any changes to your application in order to make CakePHP recognize the classes that live inside it.

This class wasn't properly loaded through autoload and even if existed there was misleading error screen.

I was able to fix this issue through 2 ways:

a.)
edit main "composer.json" in application root.
i've added "Admin\\": "./plugins/Admin/src" into following section:

"autoload": {
        "psr-4": {
            "App\\": "src",
            "Admin\\": "./plugins/Admin/src"
        }
    },

b.) in application bootstrap.php when loading plugin add "autoload => true" param in Plugin::load method.

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

otherwise Cake wasnt able recognize my plugin classes.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions