Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default drush alias in aliases.drushrc.php?

Tags:

drush

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?

like image 729
Evanss Avatar asked Jul 10 '15 13:07

Evanss


2 Answers

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

like image 155
Nikhil.nj Avatar answered Oct 20 '22 03:10

Nikhil.nj


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

like image 44
jimafisk Avatar answered Oct 20 '22 05:10

jimafisk