Error on install plugin: Your Application class does not have a bootstrap [SOLVED]


#1

In CakePHP 3.6 or 3.6.1

On load plugin with

bin/cake plugin load migrations

appear the message:
Your Application class does not have a bootstrap() method. Please add one.

Any plugin, install but not load.

In CakePHP 3.5.13 and below works fine.

Help me, please!

[HOW TO SOLVE THIS]
I create my application using CakePHP 3.5.13
Install my plugin and work fine.

Execute migrations:
composer require --update-with-dependencies “cakephp/cakephp:3.6.*”

Hidden deprecated messages in:

config/app.php

‘Error’ => [
‘errorLevel’ => E_ALL & ~E_USER_DEPRECATED,

And now my application works fine with plugin in CakePHP 3.6.1

Suggestion: core with config/app.php with

'errorLevel' => E_ALL & ~E_USER_DEPRECATED,

Thank you.


#2

go to src/Application.php and add

    public function bootstrap()
    {   
        parent::bootstrap();
    }

#3

Thank you. This dont create message and appear:

bin/cake plugin load CakeAclBr --bootstrap

/backup/www/cake361_limpo/src/Application.php modified

But when I execute:

bin/cake bake all groups -t CakeAclBr

Appear:

PHP Fatal error: Uncaught InvalidArgumentException: The plugin class CakeAclBr\Plugin cannot be found. Ensure your autoloader is correct. in /backup/www/cab_361/vendor/cakephp/cakephp/src/Http/BaseApplication.php:127
Stack trace:
#0 /backup/www/cab_361/vendor/cakephp/cakephp/src/Http/BaseApplication.php(95): Cake\Http\BaseApplication->makePlugin(‘CakeAclBr\Plugi…’, Array)
#1 /backup/www/cab_361/src/Application.php(34): Cake\Http\BaseApplication->addPlugin(‘CakeAclBr’, Array)
#2 /backup/www/cab_361/vendor/cakephp/cakephp/src/Console/CommandRunner.php(188): App\Application->bootstrap()
#3 /backup/www/cab_361/vendor/cakephp/cakephp/src/Console/CommandRunner.php(134): Cake\Console\CommandRunner->bootstrap()
#4 /backup/www/cab_361/bin/cake.php(12): Cake\Console\CommandRunner->run(Array)
#5 {main}
thrown in /backup/www/cab_361/vendor/cakephp/cakephp/src/Http/BaseApplication.php on line 127

Really. In config/bootstrap.php dont add load. Then I add manually in config/bootstrap.php

Plugin::load(‘CakeAclBr’, [‘bootstrap’ => true]);

And execute again
bin/cake bake all groups -t CakeAclBr

Again same error fatal.
And now I install migrations plugin to try:

composer require cakephp/migrations

Remove CakeAclBr from src/Application.php and

bin/cake plugin load Migrations

Modified

When execute:

bin/cake migrations migrate

Same fatal error.

And Now?


#4

The new plugin implementation in Cake 3.6 seems a little bit shifty right now. That’s why I came here this morning asking related questions: Questions about the new Cake 3.6 plugin facilities

I’m not familiar with the bin/cake bake all groups … command but I assume that removing the plugin from Application::bootstrap and just load it with Plugin::load(‘CakeAclBr’, [‘bootstrap’ => true]); in config/bootstrap.php should work OK if it did in the past.

Just skip the bin/cake plugin load … step and add it manually.


#5

Yes. Work.
But appear serious other problems.
I back to CakePHP 5.1.3 where all works fine.
Thank you.


#7

Guys, please read the migration guide and the documentation, both has been updated:

The console environment no longer automatically loads plugins specified by the --plugin option. Instead you must ensure that your application bootstrapping loads all the required plugins


#8

The problem continue.
After install and load plugin.
On execute:
bin/cake bake all groups -t CakeAclBr

I receive:

PHP Fatal error: Uncaught InvalidArgumentException: The plugin class CakeAclBr\Plugin cannot be found. Ensure your autoloader is correct.