Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Director::is_cli() and cgi-fcgi

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

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

Page: 1
Go to End
Author Topic: 397 Views
  • HansR
    Avatar
    Community Member
    140 Posts

    Director::is_cli() and cgi-fcgi Link to this post

    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

  • HansR
    Avatar
    Community Member
    140 Posts

    Re: Director::is_cli() and cgi-fcgi Link to this post

    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

    397 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.