3

I am developing a script that if run would retrieve the current stable and old stable version from http://php.net/downloads.php and compile it.

Since the version numbers change quite often and php.net may itself change layout etc (they don't provide an RSS/ atom feed), is there a way to retrieve the version numbers from a script (shell or python) that works 100%?

SpongePablo
  • 870
  • 10
  • 24
Anoop P Alias
  • 373
  • 1
  • 6
  • 15
  • Since you list bash, why not use aptitude or another package manager to do this instead? – melwil Jun 22 '15 at 07:45
  • 1
    Did you check for php.net [relesae feed](http://php.net/releases/feed.php) and [news.php.net](http://news.php.net/)? – Jonny 5 Jun 22 '15 at 08:13
  • 1
    Thanks.I think http://news.php.net/group.php?group=php.announce&format=rss is the best bet I will base my code on this – Anoop P Alias Jun 22 '15 at 08:19

5 Answers5

3

The data is provided as

Referencing: https://github.com/php/web-php/tree/master/releases

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
2

You can read the PHP Git repo in order to get the latest tags (releases).

I do not know how to do it on Python but you can extract the tags from a repo this way from a shell:

$ git describe --abbrev=0 --tags `git rev-list --tags --max-count=5`

You can change --max-count=5 to fit your needs.

Also, you could parse this page easily using some Python DOM library.

EDIT

I just found here an interesting command:

git ls-remote --tags https://github.com/php/php-src.git

This way you get all the tags from the PHP source repo without cloning it. You will need some parsing but it's an easy way to go.

Community
  • 1
  • 1
Carlos
  • 4,949
  • 2
  • 20
  • 37
1

Basing on the "bash" tag in your question, I write my solution in bash.

Rather than URLs posted in comments:

...I like PHP changelog more: even though it is HTML and not XML, it follows more strict structure. Notice how the news interchange "relased!" and "is now available", plus a wild "re:" message appears.

So I came up with this script:

wget 'https://php.net/ChangeLog-5.php' -qO -|grep h3|sed 's/<[^<>]*>//g'

Which outputs following list:

Version 5.6.10
Version 5.5.26
Version 5.4.42
Version 5.6.9
Version 5.5.25
Version 5.4.41
Version 5.6.8
Version 5.5.24
Version 5.4.40
Version 5.6.7
Version 5.5.23
Version 5.4.39
Version 5.6.6
Version 5.5.22
Version 5.4.38
Version 5.6.5
Version 5.5.21
Version 5.4.37
Version 5.6.4
Version 5.5.20
Version 5.4.36
Version 5.6.3
Version 5.5.19
Version 5.4.35
Version 5.6.2
Version 5.5.18
Version 5.4.34
Version 5.6.1
Version 5.5.17
Version 5.4.33
Version 5.6.0
Version 5.5.16
Version 5.4.32
Version 5.3.29
Version 5.5.15
Version 5.4.31
Version 5.5.14
Version 5.4.30
Version 5.5.13
Version 5.4.29
Version 5.5.12
Version 5.4.28
Version 5.5.11
Version 5.4.27
Version 5.5.10
Version 5.4.26
Version 5.5.9
Version 5.4.25
Version 5.5.8
Version 5.4.24
Version 5.5.7
Version 5.5.6
Version 5.4.23
Version 5.4.22
Version 5.5.5
Version 5.4.21
Version 5.5.4
Version 5.4.20
Version 5.5.3
Version 5.4.19
Version 5.5.2
Version 5.4.18
Version 5.5.1
Version 5.3.28
Version 5.3.27
Version 5.5.0
Version 5.4.17
Version 5.4.16
Version 5.3.26
Version 5.4.15
Version 5.3.25
Version 5.4.14
Version 5.3.24
Version 5.4.13
Version 5.3.23
Version 5.4.12
Version 5.3.22
Version 5.4.11
Version 5.3.21
Version 5.4.10
Version 5.3.20
Version 5.4.9
Version 5.3.19
Version 5.4.8
Version 5.3.18
Version 5.4.7
Version 5.3.17
Version 5.4.6
Version 5.3.16
Version 5.4.5
Version 5.3.15
Version 5.4.4
Version 5.3.14
Version 5.4.3
Version 5.3.13
Version 5.4.2
Version 5.3.12
Version 5.4.1
Version 5.3.11
Version 5.4.0
Version 5.3.10
Version 5.3.9
Version 5.3.8
Version 5.3.7
Version 5.3.6
Version 5.3.5
Version 5.2.17
Version 5.2.16
Version 5.3.4
Version 5.2.15
Version 5.3.3
Version 5.2.14
Version 5.3.2
Version 5.2.13
Version 5.3.1
Version 5.3.0
Version 5.2.12
Version 5.2.11
Version 5.2.10
Version 5.2.9
Version 5.2.8
Version 5.2.7
Version 5.2.6
Version 5.2.5
Version 5.2.4
Version 5.2.3
Version 5.2.2
Version 5.2.1
Version 5.2.0
Version 5.1.6
Version 5.1.5
Version 5.1.4
Version 5.1.3
Version 5.1.2
Version 5.1.1
Version 5.1.0
Version 5.0.5
Version 5.0.4
Version 5.0.3
Version 5.0.2
Version 5.0.1
Version 5.0.0
Version 5.0.0 Release Candidate 3
Version 5.0.0 Release Candidate 2
Version 5.0.0 Release Candidate 1
Version 5.0.0 Beta 4
Version 5.0.0 Beta 3
Version 5.0.0 Beta 2
Version 5.0.0 Beta 1

If you want to get dates and such, I recommend using BeautifulSoup + Python for this rather than bash. Dates seem to be placed in either <b></b> or <time></time> tags, although I was unable to tell the reason why.

If you however have access to git, I recommend using git ls-remote mentioned in jackflash's answer.

rr-
  • 14,303
  • 6
  • 45
  • 67
0

If you want to get current release versions you can use php.net serialized releases url format, description is on right side of page https://www.php.net/releases

You can use any client batch to get formated data and use it in script.

Example all releases in json: https://www.php.net/releases/?json

Example latest php 7.1 release in json: https://www.php.net/releases/?json&version=7.1

Madmucho
  • 101
  • 2
0

There is a free service that provides RSS and JSON data about current versions of a number of server applications like PHP, Nginx, Apache, Ruby etc:

https://current-version.com/

Mediascreen
  • 337
  • 3
  • 9