6

Ive got drush working on multiple sites with this in aliases.drushrc.php

<?php
$aliases = array(
  'site1' => array(
    'uri' => 'site1.com',
    'root' => '/Applications/MAMP/htdocs/site1/docroot',
  ),
  'site2' => array(
    'uri' => 'site2.com',
    'root' => '/Applications/MAMP/htdocs/site2/public',
  ),
);

This works great but im not only working on one site so id like to be able to leave out the site name when executing drush commands. So instead of drush @site1 cc all I could just do drush cc all. Can I do this within this file?

Evanss
  • 23,390
  • 94
  • 282
  • 505

2 Answers2

3

Try this,

$aliases['dev'] = array(
 'root' => '/path/to/drupal',
 'uri' => 'dev.mydrupalsite.com',
);

$aliases['prado'] = array(
 'root' => '/path/to/drupal',
 'uri' => 'dev.mydrupalsite.com',
);

then run following command,

drush @dev status
drush @prado status

Check here Demo Video

Nikhil.nj
  • 242
  • 1
  • 11
  • 1
    Hello jsln hope my answer was correct . There is one request to you If you got your answer then accept the answer and marked it so other one who search same they get easily right and correct answer... ['} – Nikhil.nj Aug 11 '15 at 07:20
  • You havnt answered my question. I want to be able to run drush commands without the @sitename altogether. – Evanss Aug 11 '15 at 12:37
1

The key is the "drush use" command.

So if you set up an alias at ~/.drush/aliases.drushrc.php like

 <?php
 /**
  * @file
  * Site alias
  */
 $aliases['local'] = array(
   'root' => '/var/www/drupal/web',
   'uri' => '0.0.0.0',
 );

In your terminal type drush use @local to be able to start using drush commands for your site outside of the project root without needing to specify @ which site every time, e.g. just using drush cr

jimafisk
  • 29
  • 3