Error: "Your application class does not have a bootstrap() method. Please add one."
P粉872182023
P粉872182023 2024-02-21 16:16:00
0
1
401

I recently started building an application locally using CakePHP 4.X. I installed Composer and used it to successfully install the CakePHP authentication and authorization plugin. Now I'm trying to move to some community developed plugins like

  • https://github.com/FriendsOfCake/bootstrap-ui
  • https://github.com/gutocf/page-title
  • https://github.com/dereuromark/cakephp-feedback

I can install all the plugins, but when I try to load the plugins I have a problem. Following the instructions on each plugin's Git page, I tried loading the plugin from the CLI using the following lines

bin\cake plugin load BootstrapUI

(I'm using Windows so I use backslashes)

In all cases I receive the following message:

Your Application class does not have a bootstrap() method. Please add one.

My src/Application.php file looks like this

class Application extends BaseApplication
public function bootstrap() : void
{
    // Call the parent to `require_once` config/bootstrap.php
    parent::bootstrap();

    if (PHP_SAPI === 'cli') {
        $this->bootstrapCli();
    } else {
        FactoryLocator::add(
            'Table',
            (new TableLocator())->allowFallbackClass(false)
        );
    }

    /*
     * Only try to load DebugKit in development mode
     * Debug Kit should not be installed on a production system
     */
    if (Configure::read('debug')) {
        $this->addPlugin('DebugKit');
    }

    // Load more plugins here
    $this->addPlugin('Authorization');
    $this->addPlugin('Authentication');
    $this->addPlugin('BootstrapUI');
    
}

P粉872182023
P粉872182023

reply all(1)
P粉198670603

Your application class is missing { after the class Application extends BaseApplication, but I guess it was pasted/edited incorrectly here.

Your command seems to work as I see the plugin $this->addPlugin('BootstrapUI') has been added to the file.

When executing CLI commands, make sure you are at the correct path (in the root directory of your application):

bin\cake plugin load BootstrapUI

You can add plugins manually in bootstrap() method without CLI.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!