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);

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to