Implement AmpFutureAdapter for integration with AMPHP v3 #1900
Merged
spawnia merged 15 commits intoApr 20, 2026
Conversation
This was referenced Apr 16, 2026
spawnia
requested changes
Apr 16, 2026
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
Collaborator
|
Almost there, just some static analysis configuration issue left to fix. Looking good. |
…rsions for AMP v3 examples
Contributor
Author
Fixed with commit de3f42e |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds AMPHP v3 (fiber-based) async execution support to the GraphQL PHP promise layer via a new adapter, while keeping AMPHP v2 compatibility and documenting v3 usage.
Changes:
- Introduces
AmpFutureAdapterto adaptAmp\Future(AMPHP v3) to the library’sPromiseAdapterinterface. - Extends promise typing/support to include
Amp\Future, adds tests for the new adapter, and adjusts test skipping for v2/v3 environments. - Adds AMPHP v3 examples/docs and updates tooling config (Composer + PHPStan) to accommodate optional AMPHP versions.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Executor/Promise/AmpPromiseAdapterTest.php | Skip logic added for missing AMPHP v2 at runtime. |
| tests/Executor/Promise/AmpFutureAdapterTest.php | New test suite validating AmpFutureAdapter behavior under AMPHP v3. |
| src/Executor/Promise/Promise.php | Broadens adopted promise typing to include Amp\Future. |
| src/Executor/Promise/Adapter/AmpFutureAdapter.php | New AMPHP v3 adapter implementation for Amp\Future. |
| phpstan.neon.dist | Adds ignore rules for optional/missing AMPHP types across environments. |
| examples/04-async-php/amphp-v3/schema.php | New v3 example schema using Amp\async() and Amp\Future. |
| examples/04-async-php/amphp-v3/event-loop/graphql.php | New v3 “event-loop” example endpoint wiring. |
| examples/04-async-php/amphp-v3/event-loop/README.md | v3 usage + migration notes from v2 adapter to v3 adapter. |
| examples/04-async-php/amphp-v3/http-server/graphql.php | New v3 HTTP server example integrating AmpFutureAdapter. |
| examples/04-async-php/amphp-v3/http-server/README.md | README for the v3 HTTP server example. |
| composer.json | Allows dev installs with AMPHP v2 or v3; clarifies async suggestions. |
| CHANGELOG.md | Notes addition of AmpFutureAdapter in Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tion flow in example file
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds first-class support for AMPHP v3's fiber-based async execution in the GraphQL PHP library, while maintaining compatibility with AMPHP v2. The main change is the introduction of the new
AmpFutureAdapter, which allows usingAmp\Futurefor async resolvers. The PR also includes new documentation and examples for AMPHP v3, updates to testing and composer configuration, and ensures smooth migration and compatibility.Key changes:
AMPHP v3 Support and Async Adapter:
AmpFutureAdapterinsrc/Executor/Promise/Adapter/AmpFutureAdapter.phpto enable async execution using AMPHP v3's fiber-basedAmp\Future, including full implementation of the required promise adapter interface.Promiseclass to supportAmp\Futureas a valid adopted promise type. [1] [2]Documentation and Examples:
examples/04-async-php/amphp-v3/event-loop/README.md) and an example schema and HTTP server implementation for AMPHP v3 (examples/04-async-php/amphp-v3/schema.php,examples/04-async-php/amphp-v3/event-loop/graphql.php,examples/04-async-php/amphp-v3/http-server/README.md,examples/04-async-php/amphp-v3/http-server/graphql.php). [1] [2] [3] [4] [5]Composer and Dependency Management:
composer.jsonto allow installation of both AMPHP v2 and v3 for development, and improved thesuggestsection to clarify async resolving options. [1] [2]Testing and QA:
AmpFutureAdapter(tests/Executor/Promise/AmpFutureAdapterTest.php) and improved test skipping logic for both AMPHP v2 and v3 adapters. [1] [2]phpstan.neon.distto ignore errors for missing AMPHP v2 packages in relevant test and example files.These changes collectively provide robust, documented, and tested support for async GraphQL resolvers using AMPHP v3, while preserving backward compatibility and developer guidance for both versions.