Answers.Body: <p>Nope, you've done it the best way in Craft 2.</p>
  
  <p>The upcoming Craft 3 treats console requests as more first class citizens like requests so it's not nearly as awkward using them.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-08T20:16:04.007Z
Answers.LastActivityDate: 2016-06-08T20:16:04.007Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have an install where I've moved the <code>plugins/</code> directory outside of the <code>craft/</code> directory. I've set <code>CRAFT_PLUGINS_PATH</code> in <code>index.php</code> and for web requests everything works fine.</p>
  
  <p>Now I need to run a console command defined in a plugin. When I invoke the console from my shell, the default (incorrect) value for <code>CRAFT_PLUGINS_PATH</code> is set and my plugin's console command is not available.</p>
  
  <p>I've currently worked around this by wrapping <code>craft/app/etc/console/yiic.php</code>, setting the constant before requiring <code>yiic.php</code> like so:</p>
  
  <pre><code>#!/usr/bin/env php
  &lt;?php
  
  define('CRAFT_PLUGINS_PATH', realpath(dirname(__FILE__) . "/../plugins").'/');
  
  require_once(dirname(__FILE__).'/../craft/app/etc/console/yiic.php');
  </code></pre>
  
  <p>Is there a better way to do this / am I missing something?</p>
  
Tags: <plugin-development><console>
Title: How to set CRAFT_PLUGINS_PATH when invoking a console plugin action
ThreadText: # How to set CRAFT_PLUGINS_PATH when invoking a console plugin action
  
  (Asked by: username_0 on 2016-06-08)
  
  I have an install where I've moved the `plugins/` directory outside of the `craft/` directory. I've set `CRAFT_PLUGINS_PATH` in `index.php` and for web requests everything works fine.
  
  Now I need to run a console command defined in a plugin. When I invoke the console from my shell, the default (incorrect) value for `CRAFT_PLUGINS_PATH` is set and my plugin's console command is not available.
  
  I've currently worked around this by wrapping `craft/app/etc/console/yiic.php`, setting the constant before requiring `yiic.php` like so:
  
  ```
  #!/usr/bin/env php
  <?php
  
  define('CRAFT_PLUGINS_PATH', realpath(dirname(__FILE__) . "/../plugins").'/');
  
  require_once(dirname(__FILE__).'/../craft/app/etc/console/yiic.php');
  
  ```
  
  Is there a better way to do this / am I missing something?
  
  **Tags:** plugin-development, console
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-08. Score: 1 | Accepted answer
  
  Nope, you've done it the best way in Craft 2.
  
  The upcoming Craft 3 treats console requests as more first class citizens like requests so it's not nearly as awkward using them.
  
  
  ---
  
  