Welcome Guest, Not a member yet? Register   Sign In
URL that gives the latest stable version of CI
#1

Hi,

I am wondering, is there any address, like for example codeigniter.com/version or codeigniter.com/latest, where one can get to know what the latest, stable version of CI is.

Of course everyone can just open the main page of CI Wink, but I'm interesting in a way, that can be used with cURL or wget, etc. Let's say, that I want to check with PHP if it's time to do an update of my CI.
Reply
#2

The GitHub API can help with that, although you would have to parse the response and implement the logic so that it won't give you RC tags and such: https://developer.github.com/v3/repos/#list-tags

But Composer can manage that whole process for you already, so ...
Reply
#3

(This post was last modified: 09-02-2015, 09:02 AM by jacek.ciach.)

Yes, I know Composer will do...
But I've been just curious.

If created a piece of code to check how GitHub API works. In case someone was interested (a CLI script):

PHP Code:
<?php /* get_latest_version.php */

function url_get_contents($url)
{
 $ch curl_init();
 $timeout 5/* seconds */
 $version curl_version();
 curl_setopt ($chCURLOPT_URL$url);
 curl_setopt ($chCURLOPT_RETURNTRANSFER1);
 curl_setopt ($chCURLOPT_CONNECTTIMEOUT$timeout);
 curl_setopt ($chCURLOPT_SSL_VERIFYPEERfalse);
 curl_setopt ($chCURLOPT_USERAGENT'cURL/'.$version['version']);
 $result curl_exec($ch);
 curl_close($ch);
 return $result;
}

function 
tag_version_compare($tag1$tag2)
{
 return version_compare($tag1['name'], $tag2['name']);
}

function 
get_latest_version_tag()
{
 $tags json_decode(
   url_get_contents('https://api.github.com/repos/bcit-ci/CodeIgniter/tags'),
   true
 
);

 if ($tags && empty($tags['message']))
 {
   usort($tags'tag_version_compare');
   return end($tags);
 }
 else
   return $tags
;
}

$latest_tag get_latest_version_tag();
if (isset(
$latest_tag['name']))
 echo $latest_tag['name'];
elseif (isset(
$latest_tag['message']))
 echo $latest_tag['message'];
else
{
 echo 'Cannot retrieve the latest version of CodeIgniter.';
 exit(1);

Reply




Theme © iAndrew 2016 - Forum software by © MyBB