Skip to content

Add query() route method for the HTTP QUERY verb (RFC 10008) - #3461

Open
purwantoid wants to merge 2 commits into
slimphp:4.xfrom
purwantoid:add-http-query-method
Open

Add query() route method for the HTTP QUERY verb (RFC 10008)#3461
purwantoid wants to merge 2 commits into
slimphp:4.xfrom
purwantoid:add-http-query-method

Conversation

@purwantoid

Copy link
Copy Markdown

Summary

The HTTP QUERY method was recently published as RFC 10008 on the IETF Standards Track. It is a safe, cacheable method that carries its query in the request body, enabling expressive queries without the URL-length and cacheability trade-offs of GET vs. POST. Support for QUERY is landing across the ecosystem, so this adds a query() helper as a sibling of the existing get()/post()/put()/patch()/delete()/options() route methods.

  • Adds query() to RouteCollectorProxyInterface and its implementation in RouteCollectorProxy, equivalent to map(['QUERY'], $pattern, $callable).
  • Deliberately not added to any()'s method list, so existing any() routes are unaffected.
  • Adds a CHANGELOG entry under [Unreleased] / Added.
$app->query('/search', function (Request $request, Response $response) {
    $criteria = (string) $request->getBody();
    // ...run the query described in the request body...
    return $response;
});

Test plan

  • vendor/bin/phpunit — full suite passes (437 tests)
  • vendor/bin/phpcs — clean (PSR-12)
  • vendor/bin/phpstan --memory-limit=-1 — clean (level max)
  • Added RouteCollectorProxyTest::testQuery() (unit-level, mirrors testOptions())
  • Added AppTest::testQueryRoute() (end-to-end, mirrors the GET/POST/etc. verb test)

The HTTP QUERY method was recently published as RFC 10008 on the
IETF Standards Track. It is a safe, cacheable method that carries
its query in the request body, enabling expressive queries without
the URL-length and cacheability trade-offs of GET vs. POST.

Support for QUERY is landing across the ecosystem
(https://www.rfc-editor.org/rfc/rfc10008), so this adds a query()
helper as a sibling of the existing get()/post()/put()/patch()/
delete()/options() route methods on RouteCollectorProxyInter
implemented via the existing map() mechanism:
```
$app->query('/search', function (Request $request, Response $response) {
        $criteria = (string) $request->getBody();
        // ...run the query described in the request body...
        return $response;
    });
```
`$app->query()` is equivalent to `$app->map(['QUERY'], ...)` and is not added to any(), so existing any() routes are unaffected.
@coveralls

coveralls commented Jul 29, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.455%. remained the same — purwantoid:add-http-query-method into slimphp:4.x

@odan

odan commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@akrabat I think we should add the query method for routing, but this would also be a breaking change in RouteCollectorProxyInterface. If we add it, we could use a new minor version (4.16.0). What do you think?

@akrabat

akrabat commented Aug 9, 2026

Copy link
Copy Markdown
Member

I agree we should support it. Do we have to put it in the interface? Can we use a dockblock for IDE autocomplete?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants