[web-php] master: Expose PHP version support states as JSON (#785)
| From: | Thomas Jarrand via GitHub | Date: | Thu, 22 Jun 2023 16:48:50 +0000 |
| Subject: | [web-php] master: Expose PHP version support states as JSON (#785) | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-30892@lists.php.net to get a copy of this message | ||
Author: Thomas Jarrand (Tom32i)
Committer: GitHub (web-flow)
Pusher: sgolemon
Date: 2023-06-22T11:35:32-05:00
Commit: https://github.com/php/web-php/commit/558f2f938652d74e75a259256bc4bc2e130438de
Raw diff: https://github.com/php/web-php/commit/558f2f938652d74e75a259256bc4bc2e130438de.diff
Expose PHP version support states as JSON (#785)
Changed paths:
A releases/states.php
Diff:
diff --git a/releases/states.php b/releases/states.php
new file mode 100644
index 000000000..2fc972f6b
--- /dev/null
+++ b/releases/states.php
@@ -0,0 +1,30 @@
+<?php
+$_SERVER['BASE_PAGE'] = 'releases/active.php';
+
+include_once __DIR__ . '/../include/prepend.inc';
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/branches.inc';
+
+header('Content-Type: application/json; charset=UTF-8');
+
+$states = [];
+
+function formatDate($date = null) {
+ return $date !== null ? $date->format('c') : null;
+}
+
+foreach (get_all_branches() as $major => $releases) {
+ $states[$major] = [];
+ foreach ($releases as $branch => $release) {
+ $states[$major][$branch] = [
+ 'state' => get_branch_support_state($branch),
+ 'initial_release' => formatDate(get_branch_release_date($branch)),
+ 'active_support_end' => formatDate(get_branch_bug_eol_date($branch)),
+ 'security_support_end' =>
formatDate(get_branch_security_eol_date($branch)),
+ ];
+ }
+ krsort($states[$major]);
+}
+
+krsort($states);
+
+echo json_encode($states);