I'm trying to get a basic console command for my plugin to run but not having much luck. I have created a folder called consolecommands
inside my plugin directory and have created a file called AcmeNotificationsCommand.php
.
In this file I have:
namespace Craft;
class AcmeNotificationsCommand extends BaseCommand
{
public function actionHello()
{
echo "hello";
return 0;
}
}
From the console I am running /Users/dave/acme/craft/app/framework/yiic acmenotifications hello
But yiic
comes back and says:
The following commands are available:
- migrate
- shell
So I guess it's not picking up my new console command. What am I missing?
Update:
It occurred to me that maybe I was running the wrong yiic file since I could not see the Querygen command that is in the app/consolecommands directory as expected.
So instead I tried running /Users/dave/acme/craft/app/etc/console/yiic to see what commands were available and I got the following error:
0 /Users/dave/code/acme/craft/app/Craft.php(397): CComponent->__call('getTranslatedBr...', Array)
1 /Users/dave/code/acme/craft/app/Craft.php(397): Craft\ConsoleApp->getTranslatedBrowserLanguage()
2 /Users/dave/code/acme/craft/app/etc/db/DbConnection.php(57): Craft\Craft::t('Craft can???t c...')
3 /Users/dave/code/acme/craft/app/framework/base/CModule.php(387): Craft\DbConnection->init()
4 /Users/dave/code/acme/craft/app/etc/behaviors/AppBehavior.php(41): CModule->getComponent('db')
5 [internal function]: Craft\AppBehavior->isInstalled()
6 /Users/dave/code/acme/craft/app/framework/base/CComponent.php(261): call_user_func_array(Array, Array)
7 /Users/dave/code/acme/craft/app/services/PluginsService.php(89): CComponent->__call('isInstalled', Array)
8 /Users/dave/code/acme/craft/app/services/PluginsService.php(89): Craft\ConsoleApp->isInstalled()
9 /Users/dave/code/acme/craft/app/etc/console/ConsoleApp.php(53): Craft\PluginsService->loadPlugins()
10 /Users/dave/code/acme/craft/app/framework/base/CApplication.php(165): Craft\ConsoleApp->init()
11 /Users/dave/code/acme/craft/app/framework/YiiBase.php(121): CApplication->__construct('/Users/dave/cod...')
12 /Users/dave/code/acme/craft/app/etc/console/yiic.php(76): YiiBase::createApplication('Craft\ConsoleAp...', '/Users/dave/cod...')
13 /Users/dave/code/acme/craft/app/etc/console/yiic(4): require_once('/Users/dave/cod...')
14 {main}%
I also noticed a similar error when looking at the databaseimportexport plugin. Not sure if this is a bug or whether I am still doing something wrong?