[PHP-WEBMASTER] [web-downloads] main: Mark token as required for PECL api

[email protected] (Shivam Mathur)
Newsgroups php.webmaster
Message-ID <[email protected]>
Author: Shivam Mathur (shivammathur)
Date: 2025-11-10T07:39:10+05:30

Commit: https://github.com/php/web-downloads/commit/7dd209076a8226a321090f31120d3a922789561b
Raw diff: https://github.com/php/web-downloads/commit/7dd209076a8226a321090f31120d3a922789561b.diff

Mark token as required for PECL api

Changed paths:
  M  .github/workflows/pecl.yml
  M  API.md
  M  src/Http/Controllers/PeclController.php


Diff:

diff --git a/.github/workflows/pecl.yml b/.github/workflows/pecl.yml
index c04ec24..4a2500b 100644
--- a/.github/workflows/pecl.yml
+++ b/.github/workflows/pecl.yml
@@ -20,4 +20,4 @@ jobs:
           --request POST \
           --location https://downloads.php.net/api/pecl \
           --header 'Authorization: Bearer ${{ secrets.AUTH_TOKEN }}' \
-          --data '{ "url": "${{ inputs.url }}", "extension": "${{ inputs.extension }}", "ref": "${{ inputs.ref }}" }'
+          --data '{ "url": "${{ inputs.url }}", "extension": "${{ inputs.extension }}", "ref": "${{ inputs.ref }}", "token": "${{ secrets.TOKEN }}" }'
diff --git a/API.md b/API.md
index 1bc0735..7056060 100644
--- a/API.md
+++ b/API.md
@@ -60,7 +60,7 @@ curl -i -X POST \
     - `url` (string, required, URL): Direct download URL of the artifact.
     - `extension` (string, required): Extension name (used in filename).
     - `ref` (string, required): Reference (e.g., tag/commit) used in filename.
-    - `token` (string, optional): Used as a GitHub token if the URL points to `api.github.com`.
+    - `token` (string, required): Used as a GitHub token if the URL points to `api.github.com`.
 - Success: `200 OK`.
 - Errors:
     - `400` with validation details if required fields are missing/invalid.
diff --git a/src/Http/Controllers/PeclController.php b/src/Http/Controllers/PeclController.php
index 4adbff0..a0194cd 100644
--- a/src/Http/Controllers/PeclController.php
+++ b/src/Http/Controllers/PeclController.php
@@ -16,6 +16,7 @@ public function validate(array $data): bool
             'url' => 'required|url',
             'extension' => 'required|string',
             'ref' => 'required|string',
+            'token' => 'required|string',
         ]);
 
         $validator->validate($data);
@@ -37,7 +38,7 @@ public function execute(array $data): void
                 $data['extension'],
                 $data['ref'],
                 $data['url'],
-                $data['token'] ?? ''
+                $data['token'],
             );
         } catch (Exception $exception) {
             http_response_code(500);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.