Created
October 3, 2011 13:18
-
-
Save simme/1259082 to your computer and use it in GitHub Desktop.
Drush automagic site aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Setup site aliases for local sites. | |
* | |
* Expects the following setup: | |
* SITES_DIR/ | |
* site.local/public_html | |
* site2.local/public_html | |
* | |
* @todo | |
* - Detect Drupal (if it can be done efficiently) | |
* - Some kind of cache perhaps, this might get slow | |
*/ | |
// Absolute path to sites directory | |
define('SITES_DIR', '/path/to/your/sites/'); | |
// Name of public folder | |
define('PUBLIC_DIR', 'public_html'); | |
// Local "domain" | |
define('DOMAIN', '.local'); | |
// Automatically set up local site aliases | |
$di = new DirectoryIterator(SITES_DIR); | |
foreach ($di as $dir) { | |
if ($dir->isDir() && !$dir->isDot()) { | |
$path = $dir->getPathname() . '/' . PUBLIC_DIR; | |
$aliases[$dir->getBasename(DOMAIN)] = array( | |
'uri' => $dir->getFilename(), | |
'path' => $path, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment