4

I want to specify additional php.ini settings to a drush invocation in the manner they would passed using -d option if drush was a php script that could be passed to PHP using the -f parameter.

On looking at drush shell script - /usr/bin/drush - I see that it executes the drush.php script in that manner.

Is there a way to add more of those through the command line?

2 Answers 2

7

In the Drush README file, in the section titled "CONFIGURING PHP.INI", you will find instructions on how to set php configuration variables without modifying the drush script:

export PHP_INI='/path/to/php.ini'
export DRUSH_INI='/path/to/drush.ini'
export PHP_OPTIONS='-d memory_limit="128M"'

The first option replaces the entire php.ini file with one of your choosing. The second option allows you to specify an ini file that is merged in with the standard php-cli ini file. The last option allows you to specify commandline options to set configuration values. Note that the second option effectively works the same way as the third option -- all of the settings are converted to commandline options. See the php documentation for more information on php commandline options.

If you want to do this for just one call:

alias specialdrush='/usr/bin/env PHP_OPTIONS="-f /path/to/my/php.ini" drush'
2
  • When I check the issue queues I see a '--php-options= -d x1=y1 -d x2=y2' etc. Is that option implemented, or is a method that is not implemented?
    – vfclists
    Commented Mar 2, 2014 at 4:04
  • php-options is used internally by Drush to indicate how backend invoke should call Drush. If you want to know more about php-options, you should probably ask a separate question; however, suffice it to say that this option is not useful for the purpose this question addresses. Commented Mar 2, 2014 at 4:24
3

reading through /usr/bin/drush, i found this part :

# Check to see if the user has provided a php.ini file or drush.ini file in any conf dir
# Last found wins, so search in reverse priority order
for conf_dir in "`dirname "$SELF_PATH"`" /etc/drush "$HOME/.drush" ; do
  if [ ! -d "$conf_dir" ] ; then
    continue
  fi
  # Handle paths that don't start with a drive letter on MinGW shell. Equivalent to cygpath on Cygwin.
  if [ -n "$MINGW" ] ; then
    conf_dir=`sh -c "cd \"$conf_dir\"; pwd -W"`
  fi
  if [ -f "$conf_dir/php.ini" ] ; then
    drush_php_ini="$conf_dir/php.ini"
  fi
  if [ -f "$conf_dir/drush.ini" ] ; then
    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

if i read it right, you would have to do one of these : - add a file somewhere - fill in a variable

2
  • After checking the reviewing /usr/bin/drush I have realized that I have to add modify the script to add the additional '-d' options by adding additional parameters to the call to drush will be extracted and included in the '$php_options' variable. I have upvoted @mojzis answer in the meanwhile.
    – vfclists
    Commented Mar 1, 2014 at 1:47
  • 2
    @vfclists i dont think thats optimal :) check gregs answer, its better :) and he nails it down ... no need to modify anything ...
    – mojzis
    Commented Mar 1, 2014 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.