Download & Extend

drush.ini or php.ini? [Drush should use php.ini files in drush conf folders + some fixes for drush paths that contain spaces]

Project:Drush
Version:All-versions-5.x-dev
Component:Base system (internal API)
Category:support request
Priority:minor
Assigned:greg.1.anderson
Status:closed (fixed)

Issue Summary

Some ISPs do not configure separate php.ini files for the CLI and web server. This makes it inconvenient for users to allow drush to call exec and prohibit the same in the webserver, as they must use an alias to call drush in order to specify a custom php.ini -- and forgetting to also pass your custom php-ini to drush via the --php arg means that other things will subtly fail later.

This patch modifies the drush wrapper script so that it will correctly use any php.ini file that it finds in $HOME/.drush or /etc/drush.

AttachmentSize
drush-php-ini.patch2.19 KB

Comments

#1

#2

This version of the patch is improved in several places to properly handle spaces in paths and also updates the documentation in README.txt.

AttachmentSize
drush-spaces-in-path.patch 5.37 KB

#3

Title:Drush should use any php.ini file that it finds in drush configuration folders» Drush should use php.ini files in drush conf folders + some fixes for drush paths that contain spaces (e.g. on Windows)

#4

So now there is yet another way to specify your PHP and that’s the DRUSH_PHP environment var. Can we make this system simpler instead of more complex?

Also, not sure about the alternate .ini. The folks we are trying to help are usually not capable of understanding all those settings. They just needs the ones they need like memory_limit. I would want them override like so:

php -d memory_limit=64M drush.php

Maybe we ask folks to put those php properties that they want to override in a drush.ini which they usually put in ~/.drush/php.ini or server-wide location.

#5

Still on the fence about this. Anyone have an opinion?

#6

I included the fixes for spaces in paths, plus the check for php.ini in $HOME/drush and /etc/drush in #926780: Use drush to write standard Unix scripts in php, but removed the environment variable checks.

I would opt to keep DRUSH_PHP environment variable. It is no more complex for most users, who will just use drush or drush.bat. DRUSH_PHP is simpler than defining an alias, as the alias must include --php to work correctly. I'm not set on DRUSH_PHP, though, and wouldn't mind taking it out.

I also like php.ini in $HOME/drush. For users on an ISP that does not have a separate .ini file for php-cli, it is easy to tell them to copy the php.ini shown in drush status to the appropriate location. The ini file then serves as a template for which variables to change.

I plan on circling back here to code up drush.ini per #4 when I get to it.

#7

OK, that makes good sense. I'm happy to commit all this code here or in other issues - whatever is easiest.

#8

Assigned to:Anonymous» greg.1.anderson

Should be back here soon; assigning to myself.

#9

Here is a patch that brings back the DRUSH_PHP environment variable and adds php overrides per #4. Also includes an example.drush.ini file to get people started.

AttachmentSize
drush-php-overrides.patch 5.16 KB

#10

Looks good.

Maybe some docs in README? Are there any error messages that should mention this feature. I'm thinking of open_basedir/safe mode in particular.

#11

Here's an updated patch, now with README docs and better error messages for open_basedir, safe_mode, etc.

Note that some of these settings can prevent drush from printing the helpful message; e.g. open_basedir that does not include drush kills drush before any drush code runs at all.

AttachmentSize
drush-php-ini-3.patch 10.41 KB

#12

Status:needs review» fixed

committed. thanks.

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

I just committed example.drush.ini. Forgot it when I first committed this.

#15

I'm confused about whether to name my *.ini file to "php.ini" or "drush.ini" when placed in ~/.drush/?

I'm using 4.2. I'm just using it to overside open_basedir.

#16

Title:Drush should use php.ini files in drush conf folders + some fixes for drush paths that contain spaces (e.g. on Windows)» drush.ini or php.ini? [Drush should use php.ini files in drush conf folders + some fixes for drush paths that contain spaces]
Category:feature request» support request
Status:closed (fixed)» fixed

If you name your file php.ini, then it will act as your primary (and only) .ini file. In this case, you should copy the entire php.ini file that you want to use into your .drush folder and edit it to suit.

If you use drush.ini, then the values that appear inside will override the settings in your primary .ini file. If you use drush.ini, you should only include settings that have different values than the primary .ini file.

#17

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here