Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Director::is_cli() and cgi-fcgi


Go to End


2 Posts   2678 Views

Avatar
HansR

Community Member, 141 Posts

19 February 2013 at 10:05am

The web host that my website is hosted on uses FastCGI, and so Director::is_cli() always returns false, even when running a script using cron. This is because php_sapi_name() always returns "cgi-fcgi", regardless of where php is called from.

Is there any reliable way to get is_cli() working properly? I've tried every method that I can find on the internet, including checking various $_SERVER array entries (e.g., isset($_SERVER['HTTP_USER_AGENT'])), but all of them fail.

Hans

Avatar
HansR

Community Member, 141 Posts

8 April 2013 at 7:02pm

I finally found the solution here. Simply set cron to call "php-cli" instead of "php". For example, use:
php-cli sapphire/cli-script.php /dev/tasks/ProcessJobQueueTask

instead of:
php sapphire/cli-script.php /dev/tasks/ProcessJobQueueTask

Hans