https://github.com/mohamedahmed01/http-query-polyfill
Backward-compatible polyfill for Laravel's Http::query() method (RFC 10008) on Laravel < 13.19
https://github.com/mohamedahmed01/http-query-polyfill
http laravel ployfill query
Last synced: 13 days ago
JSON representation
Backward-compatible polyfill for Laravel's Http::query() method (RFC 10008) on Laravel < 13.19
- Host: GitHub
- URL: https://github.com/mohamedahmed01/http-query-polyfill
- Owner: mohamedahmed01
- License: mit
- Created: 2026-07-12T21:03:30.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2026-07-12T21:19:14.000Z (13 days ago)
- Last Synced: 2026-07-12T23:08:47.681Z (13 days ago)
- Topics: http, laravel, ployfill, query
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel HTTP Query Polyfill
Backward-compatible polyfill for [`Http::query()`](https://github.com/laravel/framework/pull/60663) introduced in Laravel 13.19.0 (RFC 10008).
On Laravel **< 13.19**, this package registers `PendingRequest::query()` so you can send HTTP `QUERY` requests with a body. On Laravel **13.19+**, registration is skipped and the native method is used unchanged.
## Installation
```bash
composer require mohamedahmed01/laravel-http-query-polyfill
```
The service provider is auto-discovered. No further setup is required.
## Usage
Same API as Laravel 13.19+:
```php
use Illuminate\Support\Facades\Http;
$response = Http::query('https://api.example.com/search', [
'filter' => ['status' => 'active'],
]);
```
JSON is the default body format. Use existing fluent helpers for other formats:
```php
Http::asForm()->query('https://api.example.com/search', [
'filter' => 'active',
]);
```
URL query strings are unchanged — keep using `withQueryParameters()` or `Http::get($url, $query)` for those.
## Testing helpers (Laravel < 13.19)
Laravel 13.19 also added `$this->query()` / `$this->queryJson()` on HTTP tests. Those live on a trait, so they cannot be auto-registered. On older Laravel, add the polyfill trait to your base test case:
```php
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use MohamedAhmed01\HttpQueryPolyfill\Testing\MakesHttpQueryRequests;
abstract class TestCase extends BaseTestCase
{
use MakesHttpQueryRequests;
}
```
Then:
```php
$this->queryJson('/search', ['filter' => 'active'])->assertOk();
```
Do **not** use this trait on Laravel 13.19+ — the methods already exist and will collide.
## Compatibility
| Laravel | Behavior |
|---------|----------|
| 10.x – 13.18 | Macro polyfill registered |
| 13.19+ | No-op; native `Http::query()` used |
## Live integration (optional)
Against [Ayder](https://github.com/A1darbek/ayder)'s `/broker/query` QUERY endpoint:
```bash
# from an Ayder checkout
docker compose up -d --build
curl -fsS http://127.0.0.1:1109/health
# from this package
vendor/bin/phpunit --filter AyderHttpQueryIntegrationTest
```
Coverage includes:
- `Http::query()` with a JSON body against a real QUERY server
- `Accept-Query`, `ETag`, `Content-Location`
- conditional revalidation with `If-None-Match` → `304`
Tests skip automatically when Ayder is not reachable. Override with `AYDER_BASE_URL` / `AYDER_TOKEN`.
## License
MIT