<p>Sounds like you haven't enabled the plugin from Settings->Plugins.</p>

<p>Once you do that, yiic will register your plugin's custom command.</p>

CC BY-SA 3.0
2014-07-26T06:51:21.270Z
I have uninstalled and re installed the plugin but sill no joy.
Dave Coggins
CC BY-SA 3.0
2014-07-26T07:52:29.613Z
I've been hunting around trying to find a craft plugin that uses a custom command to try and work out what i'm doing wrong but can't seem to find one. Do you know of any?
Dave Coggins
CC BY-SA 3.0
2014-07-26T15:38:12.143Z
I've got one locally you can test with... email support@buildwithcraft.com.
Brad Bell
CC BY-SA 3.0
2017-01-04T18:13:40.510Z
anyone else troubleshooting needs a reference, I found the twittercraft plugin handy: https://github.com/brammittendorff/twittercraft/tree/master/consolecommands
nullvariable
CC BY-SA 3.0
2014-07-26T06:46:33.007Z
2014-07-26T06:46:33.007Z
Brad Bell
<p>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 <code>consolecommands</code> inside my plugin directory and have created a file called <code>AcmeNotificationsCommand.php</code>.</p>
<p>In this file I have:</p>
<pre><code>namespace Craft;

class AcmeNotificationsCommand extends BaseCommand
{
    public function actionHello()
    {
        echo &quot;hello&quot;;
        return 0;
    }   
}
</code></pre>
<p>From the console I am running <code>/Users/dave/acme/craft/app/framework/yiic acmenotifications hello</code></p>
<p>But <code>yiic</code> comes back and says:</p>
<pre><code>The following commands are available:
- migrate
- shell
</code></pre>
<p>So I guess it's not picking up my new console command.  What am I missing?</p>
<h2>Update:</h2>
<p>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.</p>
<p>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:</p>
<pre><code>0 /Users/dave/code/acme/craft/app/Craft.php(397): CComponent-&gt;__call('getTranslatedBr...', Array)
1 /Users/dave/code/acme/craft/app/Craft.php(397): Craft\ConsoleApp-&gt;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-&gt;init()
4 /Users/dave/code/acme/craft/app/etc/behaviors/AppBehavior.php(41): CModule-&gt;getComponent('db')
5 [internal function]: Craft\AppBehavior-&gt;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-&gt;__call('isInstalled', Array)
8 /Users/dave/code/acme/craft/app/services/PluginsService.php(89): Craft\ConsoleApp-&gt;isInstalled()
9 /Users/dave/code/acme/craft/app/etc/console/ConsoleApp.php(53): Craft\PluginsService-&gt;loadPlugins()
10 /Users/dave/code/acme/craft/app/framework/base/CApplication.php(165): Craft\ConsoleApp-&gt;init()
11 /Users/dave/code/acme/craft/app/framework/YiiBase.php(121): CApplication-&gt;__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}%
</code></pre>
<p>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?</p>

CC BY-SA 3.0
2016-12-09T16:41:58.530Z
I had a similar error when trying to use the console to generate a migration script and it lead to finding out that when called from the command line console the db.php in the config folder had to have any entry added for 'console' which is where I had to define the database, user and password as well as unixSocket entry to point to the location of the mysql.sock file used by MAMP in my case. It was the MAMP
StevenHill
CC BY-SA 3.0
2014-07-26T15:37:55.117Z
You should be running the one in craft/app/etc/console.  Not sure what the error is about, though.  Can you send a database dump over to support@buildwithcraft.com?
Brad Bell
<plugin-development>
Trouble running a plugin console command
# Trouble running a plugin console command

(Asked by: username_0 on 2014-07-26)

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?

**Tags:** plugin-development

> **Comments:**
> **username_2**: You should be running the one in craft/app/etc/console.  Not sure what the error is about, though.  Can you send a database dump over to support@buildwithcraft.com?  
> **username_1**: I had a similar error when trying to use the console to generate a migration script and it lead to finding out that when called from the command line console the db.php in the config folder had to have any entry added for 'console' which is where I had to define the database, user and password as well as unixSocket entry to point to the location of the mysql.sock file used by MAMP in my case. It was the MAMP  

---

## 1 answers

### Answer by username_2 on 2014-07-26. Score: 1

Sounds like you haven't enabled the plugin from Settings->Plugins.

Once you do that, yiic will register your plugin's custom command.

> **Comments:**
> **username_0**: I have uninstalled and re installed the plugin but sill no joy.  
> **username_0**: I've been hunting around trying to find a craft plugin that uses a custom command to try and work out what i'm doing wrong but can't seem to find one. Do you know of any?  
> **username_2**: I've got one locally you can test with... email support@buildwithcraft.com.  
> **username_3**: anyone else troubleshooting needs a reference, I found the twittercraft plugin handy: https://github.com/brammittendorff/twittercraft/tree/master/consolecommands  

---

