Skip to content

Commit

Permalink
Issue #1882426 by greg.1.anderson: Document new environment variables…
Browse files Browse the repository at this point in the history
… PHP_INI, DRUSH_INI and PHP_OPTIONS.
  • Loading branch information
greg-1-anderson committed Jan 8, 2013
1 parent b4041f2 commit 6b46616
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
15 changes: 15 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ Alternately, if you only want to override a few values, copy example.drush.ini
from the "examples" folder into $HOME/.drush or the folder /etc/drush and edit
to suit. See comments in example.drush.ini for more details.

You may also use environment variables to control the php settings that Drush
will use. There are three options:

export PHP_INI='/path/to/php.ini'

export DRUSH_INI='/path/to/drush.ini'

export PHP_OPTIONS='-d memory_limit="128M"'

In the case of PHP_INI and DRUSH_INI, these environment variables specify the
full path to a php.ini or drush.ini file, should you wish to use one that is
not in one of the standard locations described above. The PHP_OPTIONS
environment variable can be used to specify individual options that should
be passed to php on the command line when Drush is executed.

Drush requires a fairly unrestricted php environment to run in. In particular,
you should insure that safe_mode, open_basedir, disable_functions and
disable_classes are empty.
Expand Down
9 changes: 9 additions & 0 deletions drush
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ for conf_dir in "`dirname "$SELF_PATH"`" /etc/drush $HOME/.drush ; do
drush_php_override="$conf_dir/drush.ini"
fi
done
# If the PHP_INI environment variable is specified, then tell
# php to use the php.ini file that it specifies.
if [ -n "$PHP_INI" ] ; then
drush_php_ini="$PHP_INI"
fi
# If the DRUSH_INI environment variable is specified, then
# extract all ini variable assignments from it and convert
# them into php '-d' options. These will override similarly-named
# options in the php.ini file
if [ -n "$DRUSH_INI" ] ; then
drush_php_override="$DRUSH_INI"
fi
Expand All @@ -102,6 +108,9 @@ fi
if [ -n "$drush_php_override" ] ; then
php_options=`grep '^[a-z_A-Z0-9.]\+ *=' $drush_php_override | sed -e 's|\([^ =]*\) *= *\(.*\)|\1="\2"|' -e 's| ||g' -e 's|^|-d |' | tr '\n\r' ' '`
fi
# If the PHP_OPTIONS environment variable is specified, then
# its contents will be passed to php on the command line as
# additional options to use.
if [ -n "$PHP_OPTIONS" ] ; then
php_options="$php_options $PHP_OPTIONS"
fi
Expand Down
23 changes: 16 additions & 7 deletions examples/example.drush.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
; php.ini file drush is using by running "drush status".
; If the php.ini file shown is your webserver ini
; file, then rename this file, example.drush.ini,
; to drush.ini and copy it to one of the following
; to drush.ini and copy it to one of the following
; locations:
;
; 1. Drush installation folder
; 2. User's .drush folder (i.e. ~/.drush/drush.ini)
; 3. System wide configuration folder (i.e. /etc/drush/drush.ini)
;
; If the environment variable DRUSH_INI is defined,
; then the file it specified will be used as drush.ini.
;
; export DRUSH_INI='/path/to/drush.ini'
;
; When in use, the variables defined in this file
; will override the setting values that appear in
; your php.ini file. See the examples below for
Expand All @@ -32,14 +37,18 @@
; has the same value as the webserver php.ini
; to keep the size of the override list small.
;
; To fully specify the value of all php.ini variables,
; copy your webserver php.ini file to one of the
; To fully specify the value of all php.ini variables,
; copy your webserver php.ini file to one of the
; locations mentioned above (e.g. /etc/drush/php.ini)
; and edit it to suit.
; and edit it to suit. Alternately, you may use
; the environment variable PHP_INI to point at
; the file that Drush should use.
;
; export PHP_INI='/path/to/php.ini'
;
; The options listed below are particularly relevant
; to drush.
;
;

;
; drush needs as much memory as Drupal in order
Expand All @@ -64,7 +73,7 @@ display_errors = stderr
; sometimes set to restrictive values in a
; webserver's php.ini:
;
;safe_mode =
;open_basedir =
;safe_mode =
;open_basedir =
;disable_functions =
;disable_classes =

0 comments on commit 6b46616

Please sign in to comment.