我最近开始使用 CakePHP 4.X 在本地构建一个应用程序。我安装了 Composer 并使用它成功安装了 CakePHP 身份验证和授权插件。现在,我正在尝试转向一些社区开发的插件,例如
我可以安装所有插件,但是当我尝试加载插件时出现问题。根据每个插件 Git 页面上的说明,我尝试使用以下行从 CLI 加载插件
bin\cake plugin load BootstrapUI
(我使用的是 Windows,因此使用反斜杠)
在所有情况下我都会收到以下消息:
Your Application class does not have a bootstrap() method. Please add one.
我的src/Application.php文件如下所示
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');
} Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您的应用程序类在
class Application extends BaseApplication之后缺少{,但我猜它在此处粘贴/编辑不正确。您的命令似乎有效,因为我看到插件
$this->addPlugin('BootstrapUI')已添加到文件中。执行 CLI 命令时,请确保位于正确的路径(在应用程序的根目录中):
您可以在 bootstrap() 方法中手动添加插件,无需 CLI。