[php-src] Issue #19003: HTTP Requests for developing API
| From: | Mahan-Iranfar | Date: | Tue, 01 Jul 2025 20:04:06 +0000 |
| Subject: | [php-src] Issue #19003: HTTP Requests for developing API | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250361@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19003
Author: Mahan-Iranfar
### Description
To handle PUT, PATCH, and DELETE requests in PHP for API development, you'll need to manually
parse input data since PHP doesn't provide $_PUT, $_PATCH, or $_DELETE superglobals natively.
Nowadays, the development world has moved towards separating frontend and backend tasks, which
increases the need for API development compared to handling everything within a full-stack
framework. Therefore, having these superglobals is essential for PHP to regain its power and
vitality.
Continuing this thought, as frontend frameworks like AngularJS, React, and Vue.js become more
prevalent, the backend's role shifts primarily to serving APIs rather than rendering views
directly. This architectural shift demands cleaner, more efficient handling of HTTP methods beyond
GET and POST. Without native superglobals for PUT, PATCH, and DELETE, PHP developers must write
additional code to parse raw input streams, which can lead to inconsistencies and bugs. Introducing
these superglobals would align PHP more closely with modern web standards and simplify API
development workflows. It would also reduce the cognitive load on developers who currently juggle
multiple parsing strategies, allowing them to focus on business logic and improving maintainability.
Ultimately, this evolution would strengthen PHP’s position in the ecosystem, making it a more
attractive choice for building scalable, RESTful APIs in today’s decoupled frontend-backend
environments.
add this syntax:
```
$data = $_PUT['key']
$data = $_PATCH['key']
$data = $_DELETE['key']
```