2amigos / yiinitializr

Library that will help boost your application installation with ease and also to run Yii applications from its bootstrap files on a much cleaner way that the framework currently proposes.
Other
44 stars 17 forks source link

Console and SAPI name #19

Closed angelcoding closed 11 years ago

angelcoding commented 11 years ago

Just wanted to point out that Yiinitializr doesn't handle non 'cli' console connections very well. There are a couple of places in the code that check for the existence of 'cli' as the Server API (I'm also including the Yiinitializr-advanced EActiveRecord in that count too) e.g....

if (php_sapi_name() !== 'cli')

But I had problems when creating a cron job on my own server because the php_sapi_name() is actually 'cgi-fcgi' when run as a cron job (I believe there are other possibilities too).

Looks like they might have had a similar issue in the Yii core - CConsoleApplication Line 78

if(!isset($_SERVER['argv'])) // || strncasecmp(php_sapi_name(),'cli',3))
            die('This script must be run from the command line.');

Note: the php_sapi_name() part was commented out.

It would be useful if Yiinitializr can be modified in a similar way to allow the use of other SAPI names in the console.

Thanks, Steve

angelcoding commented 11 years ago

Actually, possibly not an issue after all! I forced the cron to use cli rather than cgi and that has obviously solved things. Not quite sure how you would cater for both in code anyway, so will close this as a non-issue.