1

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?

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.