-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load bootstrap_cli.php of a plugin #11184
Comments
That bake command modifies the application If plugins have cli only bootstrap code, it is up to each plugin to conditionally load it as necessary. Perhaps in the future plugins will have a more formalized pattern for this. |
Is there a way that when I use command EventManager::instance()->on(
'Bake.beforeRender.Controller.controller',
function (Event $event) {
$view = $event->getSubject();
// add the login and logout actions to the Users controller
$view->viewVars['actions'] = [
'index',
'view',
'add',
'edit',
'delete',
'online'
];
}
); |
@igorfelluga I updated your post to properly highlight the code. Please see the format and add it yourself for future posts like this. |
@igorfelluga Of course there is. // in YourPlugin/config/bootstrap.php
// other code
if (PHP_SAPI === 'cli') {
require __DIR__ . '/bootstrap_cli.php';
} |
Thanks |
Can be part of #11564 discussion. |
@markstory I tried implementing your suggestion to make "bake" use my plugin's bootstrap_cli but it didn't work. My plugin is being loaded here: app/config/bootstrap.php // rest of the file
Plugin::load('CoderThemes', ['bootstrap' => true, 'routes' => true]); app/plugins/CoderThemes/config/bootstrap.php // this is not being reached
if (PHP_SAPI === 'cli') {
require __DIR__ . '/bootstrap_cli.php';
} The code above (plugin/boostrap) never get executed when running CakePHP version: 3.6.6 Am I doing something wrong? |
Does your plugin's bootstrap file run at all? |
This is a (multiple allowed):
bug
enhancement
feature-discussion (RFC)
CakePHP Version: 3.5.2
What you did
In documentation (https://book.cakephp.org/3.0/en/console-and-shells/plugin-shell.html#loading-plugins) I found that to load bootstrap_cli of a plugin I must use bin/cake plugin load --cli MyPlugin, that add
Plugin::load('MyPlugin');
but it didn't load it.
The text was updated successfully, but these errors were encountered: