Skip to content

Instantly share code, notes, and snippets.

@alex-moreno
Created November 4, 2020 17:43
Show Gist options
  • Save alex-moreno/13b434b4acff3ce5ee3c569883ddb7fb to your computer and use it in GitHub Desktop.
Save alex-moreno/13b434b4acff3ce5ee3c569883ddb7fb to your computer and use it in GitHub Desktop.
Execute drush for a given list of sites
<?php
// clearcacheall.php alias/druh >> cacheclear.log
$list_sites = [];
$drush_alias = $argv[1];
// Iterate on them to execute the drush command.
foreach ($list_sites as $site) {
execDrushCommand($site['alias'], $drush_alias);
}
/**
* Execute drush.
*
* @param [type] $site_alias
* @param [type] $drush_alias
* @return void
*/
function execDrushCommand($site_alias, $drush_alias)
{
// Iterate on them to execute the drush command.
$result = exec("drush $drush_alias -l $site_alias [COMMAND_HERE] ", $output, $return);
echo "Result:: ";
print_r($result);
echo "Output:: ";
print_r($output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment