Command line scripts must define CLI_SCRIPT before requiring config.php error when accessing moodle

I was trying to run a php command line script inside moodle directory and got this error:

~# php myscript.php

Command line scripts must define CLI_SCRIPT before requiring config.php error when accessing moodle


To get rid of that error, put this line above config.php include code:

define('CLI_SCRIPT', true);
require_once(dirname(__FILE__) . '/../config.php');


Reference:

https://moodle.org/mod/forum/discuss.php?d=183170

Comments