Created
February 1, 2016 09:41
-
-
Save clarkphp/b3260e88e8914fc05081 to your computer and use it in GitHub Desktop.
Keeping Tools Up to Date
This file contains hidden or 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
#!/usr/bin/bash | |
# On Windows, using Gitbash and Zend Studio PHP binary. This file not be needed for *nix with PHP truly "installed." | |
# Kind of lame, but I use this to run php scripts: | |
# $ ./php.sh update-all-my-qa-tools.php | |
/c/Program\ Files/Zend/Zend\ Studio\ 13.0.0/plugins/com.zend.php.debug.debugger.php56.win32_13.0.1.v20151112-2045/resources/php56/php "$@" |
This file contains hidden or 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 | |
// Here, a Windows/GitBash focus. Easily adapted for *nix. | |
$httpsContext = stream_context_create( | |
['ssl' => | |
['cafile' => 'C:\\Program Files\\Git\\usr\\ssl\\certs\\ca-bundle.crt"'] | |
] | |
); | |
const PHP_EXE = 'C:\\Program Files\\Zend\\Zend Studio 13.0.0\\plugins\\com.zend.php.debug.debugger.php56.win32_13.0.1.v20151112-2045\\resources\\php56\\php.exe'; | |
const BUILDTOOLS = 'C:\\Users\\clark.e\\PHP-Build-Tools'; | |
$phars = [ | |
['toolname' => 'Phing', 'uri' => 'http://www.phing.info/get/phing-latest.phar', 'pharname' => 'phing-latest.phar'], | |
// first time only: ['toolname' => 'Deployer', 'uri' => 'http://deployer.org/deployer.phar', 'pharname' => 'deployer.phar'], | |
['toolname' => 'ZendServerSDK', 'uri' => 'https://github.com/zend-patterns/ZendServerSDK/raw/master/bin/zs-client.phar', 'pharname' => 'zs-client.phar'], | |
]; | |
foreach ($phars as $tool) { | |
$data = null; | |
print "Updating {$tool['toolname']}..." . PHP_EOL; | |
$context = $tool['uri'][4] === 's' | |
? $httpsContext | |
: null; | |
if (false === ($data = file_get_contents($tool['uri'], false, $context))) { | |
exit("Error accessing {$tool['toolname']} phar" . PHP_EOL); | |
} | |
if (false === file_put_contents(BUILDTOOLS . "/{$tool['pharname']}", $data)) { | |
exit("Error writing {$tool['toolname']} phar" . PHP_EOL); | |
} | |
print "{$tool['toolname']} updated." . PHP_EOL; | |
} | |
$context = null; | |
$phars = [ | |
['toolname' => 'Deployer', 'pharname' => 'deployer.phar'], | |
]; | |
foreach ($phars as $tool) { | |
print "Updating {$tool['toolname']}..." . PHP_EOL; | |
$output = shell_exec('"' . PHP_EXE . '" ' . BUILDTOOLS . "\\{$tool['pharname']} --self-update"); | |
print $output . PHP_EOL; | |
} |
This file contains hidden or 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 | |
// Here, a Windows/GitBash focus. Easily adapted for *nix. | |
$httpsContext = stream_context_create( | |
['ssl' => | |
['cafile' => 'C:\\Program Files\\Git\\usr\\ssl\\certs\\ca-bundle.crt"'] | |
] | |
); | |
const PHP_EXE = 'C:\\Program Files\\Zend\\Zend Studio 13.0.0\\plugins\\com.zend.php.debug.debugger.php56.win32_13.0.1.v20151112-2045\\resources\\php56\\php.exe'; | |
const QATOOLS = 'C:\\Users\\clark.e\\PHP-QA-Tools'; | |
print 'Get current version of Behat manually from https://github.com/Behat/Behat/releases page.' . PHP_EOL; | |
$phars = [ | |
['toolname' => 'Codeception', 'uri' => 'http://codeception.com/codecept.phar', 'pharname' => 'codecept.phar'], | |
['toolname' => 'PDepend', 'uri' => 'http://static.pdepend.org/php/latest/pdepend.phar', 'pharname' => 'pdepend.phar'], | |
['toolname' => 'CodeSniffer Code Fixer', 'uri' => 'https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar', 'pharname' => 'phpcbf.phar'], | |
['toolname' => 'CodeSniffer Tokenizer', 'uri' => 'https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar', 'pharname' => 'phpcs.phar'], | |
['toolname' => 'PHPCPD', 'uri' => 'https://phar.phpunit.de/phpcpd.phar', 'pharname' => 'phpcpd.phar'], | |
['toolname' => 'PHPLOC', 'uri' => 'https://phar.phpunit.de/phploc.phar', 'pharname' => 'phploc.phar'], | |
['toolname' => 'PHP Mess Detector', 'uri' => 'http://static.phpmd.org/php/latest/phpmd.phar', 'pharname' => 'phpmd.phar'], | |
['toolname' => 'PHP Metrics', 'uri' => 'https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar', 'pharname' => 'phpmetrics.phar'], | |
]; | |
foreach ($phars as $tool) { | |
$data = null; | |
print "Updating {$tool['toolname']}..." . PHP_EOL; | |
$context = $tool['uri'][4] === 's' | |
? $httpsContext | |
: null; | |
if (false === ($data = file_get_contents($tool['uri'], false, $context))) { | |
exit("Error accessing {$tool['toolname']} phar" . PHP_EOL); | |
} | |
if (false === file_put_contents(QATOOLS . "/{$tool['pharname']}", $data)) { | |
exit("Error writing {$tool['toolname']} phar" . PHP_EOL); | |
} | |
print "{$tool['toolname']} updated." . PHP_EOL; | |
} | |
$phars = [ | |
['toolname' => 'PHPUnit 4', 'pharname' => 'phpunit-4.phar '], | |
['toolname' => 'PHPUnit 5', 'pharname' => 'phpunit-5.phar '], | |
]; | |
foreach ($phars as $tool) { | |
print "Updating {$tool['toolname']}..." . PHP_EOL; | |
$output = shell_exec('"' . PHP_EXE . '" ' . QATOOLS . "\\{$tool['pharname']} --self-update"); | |
print $output . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment