Skip to content

Undefined method Artisan::add #1401

@webbati

Description

@webbati

Winter CMS Build

dev-develop

PHP Version

8.4

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

Using Artisan::add in init.php file how described here https://wintercms.com/docs/v1.2/docs/console/introduction#registering-a-console-command i get this error Call to undefined method Winter\Storm\Foundation\Console\Kernel::add()

Steps to replicate

Create a init.php file in the root of your plugin then add your console command with:

Artisan::add(new MyAuthor\MyPlugin\Console\MyCommand);

Workaround

Use registerConsoleCommand helper method in the register method of a Plugin registration file

class MyPlugin extends PluginBase
{
    public function register()
    {
        $this->registerConsoleCommand('myauthor.mycommand', \MyAuthor\MyPlugin\Console\MyCommand::class);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions