Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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'
share|improve this answer
    
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 Mar 2 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. –  greg_1_anderson Mar 2 at 4:24

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

share|improve this answer
    
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 Mar 1 at 1:47
1  
@vfclists i dont think thats optimal :) check gregs answer, its better :) and he nails it down ... no need to modify anything ... –  mojzis Mar 1 at 2:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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