Skip to content

Instantly share code, notes, and snippets.

@t10u
Created January 23, 2012 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t10u/1663087 to your computer and use it in GitHub Desktop.
Save t10u/1663087 to your computer and use it in GitHub Desktop.
Download Magento CE module
#!/usr/bin/env php
<?php
if (!isset($argv[1])) {
echo 'Magento extension key is required. Example usage: php '. $argv[0]. ' <Magento Connect 2.0 extension key>'. PHP_EOL;
exit(-1);
}
$mage_module_key = $argv[1];
$mage_module_name = basename($mage_module_key);
$releases_url = $mage_module_key. '/releases.xml';
$releases = simplexml_load_file($releases_url);
$versions = array();
foreach ($releases as $release) {
$versions[] = (string) $release->v;
}
asort($versions);
$latest_version = array_pop($versions);
$download_url = sprintf('%s/%s/%s-%s.tgz', $mage_module_key, $latest_version, $mage_module_name, $latest_version);
exec('wget '. $download_url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment