Created
March 10, 2012 09:46
-
-
Save roderik/2010997 to your computer and use it in GitHub Desktop.
A small snippet to find the latest stable release of Symfony 2
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 | |
$githubUser = 'symfony'; | |
$githubRepo = 'symfony'; | |
// Get GitHub JSON request | |
$githubUrl = 'http://github.com/api/v2/json/repos/show/'.$githubUser.'/'.$githubRepo.'/tags'; | |
$githubJSONResponse = file_get_contents($githubUrl); | |
// Convert it to a PHP object | |
$githubResponseArray = json_decode($githubJSONResponse, true); | |
$tagList = array_keys($githubResponseArray["tags"]); | |
// Filter out non final tags | |
$filteredTagList = array_filter($tagList, "tagfilter"); | |
function tagfilter($tag) { | |
return !stripos($tag, "-") && !stripos($tag, "PR") && !stripos($tag, "BETA") && stripos($tag, "v2.0") === 0; | |
} | |
// Sort tags | |
natcasesort($filteredTagList); | |
// The first one is the last stable release for Symfony 2 | |
$reverseFilteredTagList = array_reverse($filteredTagList); | |
echo $reverseFilteredTagList[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment