How to get the latest php version information from php.net
I am developing a script what if run would fetch the current stable and old stable version from http://php.net/downloads.php and compile it.
Since version numbers change quite often and php.net can change layout itself, etc. (they don't provide an RSS / atom feed), is there a way to get version numbers from a script (shell or python) that works 100%?
source to share
You can read the PHP Git repo to get the latest tags (releases).
I don't know how to do it in Python, but you can extract the tags from the repo this way from the shell:
$ git describe --abbrev=0 --tags `git rev-list --tags --max-count=5`
You can change --max-count=5
according to your needs.
Also, you can easily parse this page using some Python DOM library.
EDIT
I just found an interesting command here :
git ls-remote --tags https://github.com/php/php-src.git
This way you get all tags from the original PHP source without cloning. You will need parsing, but this is the easy way.
source to share
Data is provided as
- JSON http://php.net/releases/active.php
- RSS (Atom Feed) http://php.net/releases/feed.php
source to share
Based on the bash tag in your question, I am writing my solution in bash.
Instead of the urls posted in the comments:
... I like the PHP changelog better: although it is HTML and not XML, it follows a stricter structure. Notice how the news sharing "stopped!" and "now available" plus the wild "re:" message comes up.
So, I came up with this script:
wget 'https://php.net/ChangeLog-5.php' -qO -|grep h3|sed 's/<[^<>]*>//g'
Which outputs the 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 that, not bash. Dates seem to be put in tags <b></b>
or <time></time>
, although I couldn't tell the reason.
If you have git access, I recommend using the git ls-remote
one mentioned in jackflash's answer.
source to share
If you want to get the current release versions, you can use the php.net serialized release URL format, the description is on the right side of the page https://www.php.net/releases.
You can use any client package to get formatted data and use it in a script.
Example of all releases in json: https://www.php.net/releases/?json
An example of the latest php 7.1 in json: https://www.php.net/releases/?json&version=7.1
source to share