php cfg.php –help
Displays the current value of the given site setting. Allows to set it to the given value, too.
Usage:
# php cfg.php [–component=] [–json] [–shell-arg]
# php cfg.php –name= [–component=] [–shell-arg] [–no-eol]
# php cfg.php –name= [–component=] –set=
# php cfg.php –name= [–component=] –unset
# php cfg.php [–help|-h]
Options:
-h –help Print this help.
–component= Name of the component the variable is part of. Defaults to core.
–name= Name of the configuration variable to get/set. If missing, print all
configuration variables of the given component.
–set= Set the given variable to this value.
–unset Unset the given variable.
–shell-arg Escape output values so that they can be directly used as shell script arguments.
–json Encode output list of values using JSON notation.
–no-eol Do not include the trailing new line character when printing the value.
The list of all variables of the given component can be printed as
tab-separated list (default) or JSON object (–json). Particular values are
printed as raw text values, optionally escaped so that they can be directly
used as shell script arguments (–shell-arg). Single values are displayed with trailing new line by default, unless explicitly disabled (–no-eol).
In the read mode, the script exits with success status 0 if the requested value is found. If the requested variable is not set, the script exits with status 3.
When listing all variables of the component, the exit status is always 0 even
if no variables for the given component are found. When setting/unsetting a value, the exit status is 0. When attempting to set/unset a value that has
already been hard-set in config.php, the script exits with error status 4. In
case of unexpected error, the script exits with error status 1.
Examples:
# php cfg.php
Prints tab-separated list of all core configuration variables and their values.
# php cfg.php --json
Prints list of all core configuration variables and their values as a JSON object.
# php cfg.php --name=release
Prints the given configuration variable - e.g. $CFG->release in this case.
# php cfg.php --component=tool_recyclebin
# Prints tab-separated list of the plugin's configuration variables.
# export DATAROOT=$(php cfg.php --name=dataroot --shell-arg --no-eol)
Stores the given configuration variable in the shell variable, escaped
so that it can be safely used as a shell argument.
# php cfg.php --name=theme --set=classic
Sets the given configuration variable to the given value.
# php cfg.php --name=noemailever --unset
Unsets the previously configured variable.
Handy when upgrading and there is an incompatible theme from old version of Moodle upgraded.
php cfg.php --name=allowthemechangeonurl --set=1
Would then allow browser /?theme=boost or whatever was upgraded code theme default.