Issue #1936866 by jonhattan: Drush dl needs to put files in /modules or /themes,...
[project/drush.git] / README.txt
1
2 DESCRIPTION
3 ===========
4
5 Drush is a command line shell and Unix scripting interface for Drupal.  If you
6 are unfamiliar with shell scripting, reviewing the documentation for your shell
7 (e.g. man bash) or reading an online tutorial (e.g. search for "bash tutorial")
8 will help you get the most out of Drush.
9
10 Drush core ships with lots of useful commands for interacting with code like
11 modules/themes/profiles. Similarly, it runs update.php, executes sql queries
12 and DB migrations, and misc utilities like run cron or clear cache.
13
14
15 REQUIREMENTS
16 ============
17
18 * To use Drush from the command line, you'll need a CLI-mode capable PHP binary
19   version 5.3 or greater.
20
21 * Drush commands that work with git require git 1.7 or greater.
22
23 * Drush is designed for a Unix-like OS (Linux, OS X)
24
25 * Most Drush commands run on Windows.  See INSTALLING DRUSH ON WINDOWS, below.
26
27 * Drush works with Drupal 6, Drupal 7, and usually Drupal 8.
28
29
30 INSTALLATION
31 ============
32
33 The preferred way to install Drush is via our PEAR channel. See instructions at
34 http://drupal.org/project/drush. If you prefer a more manual install, see
35 below.
36
37 1. Place the uncompressed drush.tar.gz, drush.zip, or cloned git repository in
38    a directory that is outside of your web root.
39
40 2. Make the 'drush' command executable:
41
42      $ chmod u+x /path/to/drush/drush
43
44 3. Configure your system to recognize where Drush resides. There are 2 options:
45
46   a) create a symbolic link to the Drush executable in a directory that is
47      already in your PATH, e.g.:
48
49        $ ln -s /path/to/drush/drush /usr/bin/drush
50
51   b) explicitly add the Drush executable to the PATH variable which is defined
52      in the the shell configuration file called .profile, .bash_profile,
53      .bash_aliases, or .bashrc that is located in your home folder, i.e.:
54
55        export PATH="$PATH:/path/to/drush:/usr/local/bin"
56
57      Your system will search path options from left to right until it finds a
58      result.
59
60      To apply your changes to your current session, either log out and then log
61      back in again, or re-load your bash configuration file, i.e.:
62
63        $ source .bashrc
64
65   NOTE: If you do not follow step 3, you will need to inconveniently run Drush
66   commands using the full path to the executable "/path/to/drush/drush" or by
67   navigating to /path/to/drush and running "./drush". The -r or -l options will
68   be required (see USAGE, below).
69
70 4. Test that Drush is found by your system:
71
72   $ which drush
73
74 5. Optional. Help the Drush development team by sending anonymized usage
75    statistics.  To automatically send usage data, please add the following to a
76    .drushrc.php file:
77
78      $options['drush_usage_log'] = TRUE;
79      $options['drush_usage_send'] = TRUE;
80
81    Stats are usually logged locally and sent whenever log file exceeds 50Kb.
82    Alternatively, one may disable automatic sending and instead use usage-view
83    and usage-send commands to more carefully send data.
84
85 6. Optional. See examples/example.bashrc for instructions on how to add some
86    useful shell aliases that provides even tighter integration between
87    drush and bash. You may source this file directly into your shell by adding to
88    your .bashrc (rr equivalent): source /path/to/drush/examples/example.bashrc
89
90 7. Optional. If you didn't source it in Step 6 above, see top of
91    drush.complete.sh file for instructions adding bash completion for drush
92    command to your shell.  Once configured, completion works for site aliases,
93    command names, shell aliases, global options, and command-specific options.
94
95 8. Optional. If drush.complete.sh is being sourced (ideally in
96    bash_completion.d), you can use the supplied __drush_ps1() sh function to
97    add your current drush site (set with `drush use @sitename`) to your PS1
98    prompt like so:
99
100       if [ "\$(type -t __git_ps1)" ] && [ "\$(type -t __drush_ps1)" ]; then
101         PS1='\u@\h \w$(__git_ps1 " (%s)")$(__drush_ps1 "[%s]")\$ '
102       fi
103
104    Putting this in a .bashrc/.bash_profile/.profile would produce this prompt:
105
106      msonnabaum@hostname ~/repos/drush (master)[@sitename]$
107
108 ADDITIONAL CONFIGURATIONS FOR MAMP:
109 -----------------------------------
110
111 Users of MAMP will need to manually specify in their PATH which version of php
112 and MySQL to use in the command line interface. This is independent of the php
113 version selected in the MAMP application settings.  Under OS X, edit (or create
114 if it does not already exist) a file called .bash_profile in your home folder.
115
116 To use php 5.3.x, add this line to .bash_profile:
117
118   export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH"
119
120 If you want to use php 5.4.x, add this line instead:
121
122   export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4/bin:$PATH"
123
124 If you have MAMP v.1.84 or lower, this configuration will work for both version
125 of PHP:
126
127   export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:$PATH"
128
129 If you have done this and are still getting a "no such file or directory" error
130 from PDO::__construct, try this:
131
132   sudo mkdir /var/mysql
133   sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
134
135 Additionally, you may need to adjust your php.ini settings before you can use
136 drush successfully. See CONFIGURING PHP.INI below for more details on how to
137 proceed.
138
139 ADDITIONAL CONFIGURATIONS FOR OTHER AMP STACKS:
140 -----------------------------------------------
141
142 Users of other Apache distributions such as XAMPP, or Acquia's Dev Desktop will
143 want to ensure that its php can be found by the command line by adding it to
144 the PATH variable, using the method in 3.b above. Depending on the version and
145 distribution of your AMP stack, PHP might reside at:
146
147   /Applications/acquia-drupal/php/bin   Acquia Dev Desktop (Mac)
148   /Applications/xampp/xamppfiles/bin    XAMP (Mac)
149   /opt/lampp/bin                        XAMPP (Windows)
150
151 Additionally, you may need to adjust your php.ini settings before you can use
152 drush successfully. See CONFIGURING PHP.INI below for more details on how to
153 proceed.
154
155 CUSTOM CONFIGURATIONS:
156 ----------------------
157
158 Running a specific php-cli version for Drush
159 - - - - - - - - - - - - - - - - - - - - - - -
160
161   If you want to run Drush with a specific version of php, rather than the
162   php-cli defined by your system, you can add an environment variable to your
163   the shell configuration file called .profile, .bash_profile, .bash_aliases,
164   or .bashrc that is located in your home folder:
165
166     export DRUSH_PHP='/path/to/php'
167
168 CONFIGURING PHP.INI
169 -------------------
170
171 Usually, php is configured to use separate php.ini files for the web server and
172 the command line. Make sure that Drush's php.ini is given as much memory to
173 work with as the web server is; otherwise, Drupal might run out of memory when
174 Drush bootstraps it.
175
176 To see which php.ini file Drush is using, run:
177
178   $ drush status
179
180 To see which php.ini file the webserver is using, use the phpinfo() function in
181 a .php web page.  See http://drupal.org/node/207036.
182
183 If Drush is using the same php.ini file as the web server, you can create a
184 php.ini file exclusively for Drush by copying your web server's php.ini file to
185 the folder $HOME/.drush or the folder /etc/drush.  Then you may edit this file
186 and change the settings described above without affecting the php enviornment
187 of your web server.
188
189 Alternately, if you only want to override a few values, copy example.drush.ini
190 from the "examples" folder into $HOME/.drush or the folder /etc/drush and edit
191 to suit.  See comments in example.drush.ini for more details.
192
193 You may also use environment variables to control the php settings that Drush
194 will use.  There are three options:
195
196     export PHP_INI='/path/to/php.ini'
197
198     export DRUSH_INI='/path/to/drush.ini'
199
200     export PHP_OPTIONS='-d memory_limit="128M"'
201
202 In the case of PHP_INI and DRUSH_INI, these environment variables specify the
203 full path to a php.ini or drush.ini file, should you wish to use one that is
204 not in one of the standard locations described above.  The PHP_OPTIONS
205 environment variable can be used to specify individual options that should
206 be passed to php on the command line when Drush is executed.
207
208 Drush requires a fairly unrestricted php environment to run in.  In particular,
209 you should insure that safe_mode, open_basedir, disable_functions and
210 disable_classes are empty.
211
212 INSTALLING DRUSH ON WINDOWS:
213 ----------------------------
214
215 Windows support has improved, but is still lagging. For full functionality,
216 consider using on Linux/Unix/OSX using Virtualbox or other virtual machine.
217
218 There is a Windows msi installer for drush available at:
219
220   http://www.drush.org/drush_windows_installer.
221
222 Please see that page for more information on running Drush on Windows.
223
224 Whenever the documentation or the help text refers to 'drush [option]
225 <command>' or something similar, 'drush' may need to be replaced by
226 'drush.bat'.
227
228 Additional Drush Windows installation documentation can be found at
229 http://drupal.org/node/594744.
230
231 Most Drush commands will run in a Windows CMD shell or PowerShell, but the
232 Git Bash shell provided by the 'Git for Windows' installation is the preferred
233 shell in which to run Drush commands. For more information on "Git for Windows'
234 visit http://msysgit.github.com/.
235
236 When creating aliases for Windows remote machines, pay particular attention to
237 information presented in the example.aliases.drushrc.php file, especially when
238 setting values for 'remote-host' and 'os', as these are very important when
239 running Drush rsync and Drush sql-sync commands.
240
241
242 USAGE
243 =====
244
245 Once you have completed the installation steps, Drush can be run in your shell
246 by typing "drush" from within any Drupal root directory.
247
248   $ drush [options] <command> [argument1] [argument2]
249
250 Use the 'help' command to get a list of available options and commands:
251
252   $ drush help
253
254 For even more documentation, use the 'topic' command:
255
256   $ drush topic
257
258 For a full list of Drush commands and documentation by version, visit
259 http://drush.ws.
260
261 Many commands support a --pipe option which returns machine readable output.
262 For example, return a list of enabled modules:
263
264   $ drush pm-list --type=module --status=enabled --pipe
265
266 For multisite installations, use the -l option to target a particular site.  If
267 you are outside the Drupal web root, you might need to use the -r, -l or other
268 command line options just for Drush to work. If you do not specify a URI with
269 -l and Drush falls back to the default site configuration, Drupal's
270 $GLOBAL['base_url'] will be set to http://default.  This may cause some
271 functionality to not work as expected.
272
273   $ drush -l http://example.com pm-update
274
275 Related Options:
276   -r <path>, --root=<path>      Drupal root directory to use
277                                 (defaults to current directory or anywhere in a
278                                 Drupal directory tree)
279   -l <uri> , --uri=<uri>        URI of the Drupal site to use
280   -v, --verbose                 Display verbose output.
281
282 Very intensive scripts can exhaust your available PHP memory. One remedy is to
283 just restart automatically using bash. For example:
284
285   while true; do drush search-index; sleep 5; done
286
287
288 DRUSH CONFIGURATION FILES
289 =========================
290
291 Inside /path/to/drush/examples you will find some example files to help you get
292 started with your Drush configuration file (example.drushrc.php), site alias
293 definitions (example.aliases.drushrc.php) and Drush commands
294 (sandwich.drush.inc). You will also see an example 'policy' file which can be
295 customized to block certain commands or arguments as required by your
296 organization's needs.
297
298 DRUSHRC.PHP
299 -----------
300
301 If you get tired of typing options all the time you can contain them in a
302 drushrc.php file. Multiple Drush configuration files can provide the
303 flexibility of providing specific options in different site directories of a
304 multi-site installation. See example.drushrc.php for examples and installation
305 details.
306
307 SITE ALIASES
308 ------------
309
310 Drush lets you run commands on a remote server, or even on a set of remote
311 servers.  Once defined, aliases can be references with the @ nomenclature, i.e.
312
313   # Syncronize staging files to production
314   $ drush rsync @staging:%files/ @live:%files
315
316   # Syncronize database from production to dev, excluding the cache table
317   $ drush sql-sync --structure-tables-key=custom --no-cache @live @dev
318
319 See http://drupal.org/node/670460 and example.aliases.drushrc.php for more
320 information.
321
322 COMMANDS
323 --------
324
325 Drush can be extended to run your own commands. Writing a Drush command is no
326 harder than writing simple Drupal modules, since they both follow the same
327 structure.
328
329 See examples/sandwich.drush.inc for light details on the internals of a Drush
330 command file.  Otherwise, the core commands in Drush are good models for your
331 own commands.
332
333 You can put your Drush command file in a number of places:
334
335   a) In a folder specified with the --include option (see `drush topic
336      docs-configuration`).
337
338   b) Along with one of your enabled modules. If your command is related to an
339      existing module, this is the preferred approach.
340
341   c) In a .drush folder in your HOME folder. Note, that you have to create the
342      .drush folder yourself.
343
344   d) In the system-wide Drush commands folder, e.g. /usr/share/drush/commands.
345
346   e) In Drupal's /drush or sites/all/drush folders. Note, that you have to create the
347      drush folder yourself.
348
349 In any case, it is important that you end the filename with ".drush.inc", so
350 that Drush can find it.
351
352
353 FAQ
354 ===
355
356   Q: What does "drush" stand for?
357   A: The Drupal Shell.
358
359   Q: How do I pronounce Drush?
360   A: Some people pronounce the dru with a long u like Drupal. Fidelity points
361      go to them, but they are in the minority. Most pronounce Drush so that it
362      rhymes with hush, rush, flush, etc. This is the preferred pronunciation.
363
364
365 CREDITS
366 =======
367
368 * Originally developed by Arto Bendiken <http://bendiken.net/> for Drupal 4.7.
369 * Redesigned by Franz Heinzmann (frando) <http://unbiskant.org/> in May 2007 for Drupal 5.
370 * Maintained by Moshe Weitzman <http://drupal.org/moshe> with much help from
371   Owen Barton, greg.1.anderson, jonhattan, Mark Sonnabaum, and Jonathan Hedstrom.