smithy / protocol-aws
AWS protocol implementations (JSON 1.0/1.1, REST JSON, REST XML, Query, EC2 Query) for Smithy PHP.
Requires
- php: >=8.2
- ext-libxml: *
- ext-simplexml: *
- psr/http-message: ^2.0
- smithy/codec: 0.1.0-RC.7
- smithy/core: 0.1.0-RC.7
- smithy/http: 0.1.0-RC.7
- smithy/protocol: 0.1.0-RC.7
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 23:31:42 UTC
README
AWS protocol implementations for Smithy PHP: AWS JSON 1.0 and 1.1, REST JSON, REST XML, AWS Query, and EC2 Query. Requires PHP 8.2 or later.
This package owns the Smithy\Protocol\Aws namespace, a sub-namespace of
smithy/protocol. Classes keep their Smithy\Protocol\Aws\* names.
Installation
composer require smithy/protocol-aws
AWS errors
Unmodeled errors are built from the operation's service exception class when
it implements AwsErrorInterface, and from AwsProtocolException otherwise.
The deserializer calls fromAwsError() with the AWS error code, request ID and
HTTP status, and calls setRetryAfter() when the response has an
x-amz-retry-after hint. Each fromAwsError() builds its own class with
new self(); a generated service exception declares it again so unmodeled
errors keep the service type. Modeled errors that implement AwsErrorInterface receive the same
metadata through setAwsErrorMetadata() after their members are
deserialized; the envelope message becomes the exception message when the
modeled message is empty. AwsErrorRetryTrait supplies the status-based
retry classification, so SDK base exceptions can implement the interface on
their own hierarchy.
Read the metadata with getAwsErrorCode(), getAwsRequestId() and
getHttpStatusCode(). Errors that implement AwsExtendedRequestIdInterface
(including AwsProtocolException) also carry an extended request ID, such as
the Amazon S3 x-amz-id-2 value, through getExtendedRequestId().
AWS JSON
AwsJson1_0ClientProtocol implements aws.protocols#awsJson1_0 with AWS JSON RPC
framing, the application/x-amz-json-1.0 content type, and AWS JSON error
envelopes.
use Smithy\Protocol\Aws\AwsJson1_0ClientProtocol; $protocol = new AwsJson1_0ClientProtocol($service);
AwsJson1_1ClientProtocol implements aws.protocols#awsJson1_1 with AWS JSON RPC
framing, the application/x-amz-json-1.1 content type, and AWS JSON error
envelopes.
use Smithy\Protocol\Aws\AwsJson1_1ClientProtocol; $protocol = new AwsJson1_1ClientProtocol($service);
Query-compatible services
A service marked aws.protocols#awsQueryCompatible keeps the error codes of
the AWS Query protocol. AwsJson1_0ClientProtocol, AwsJson1_1ClientProtocol and
AwsRpcV2CborClientProtocol read the trait from the service. For
these services they send x-amzn-query-mode: true and expose the error code
and fault from the x-amzn-query-error response header. The header holds
Code;Sender or Code;Receiver. Sender is a client fault and Receiver is
a server fault.
AwsRpcV2CborClientProtocol extends RpcV2CborClientProtocol and shares
its protocol ID, so a registry that holds it serves every AWS rpcv2Cbor
service.
AWS Rest JSON
RestJsonClientProtocol implements aws.protocols#restJson1 with Smithy HTTP
bindings, the JSON codec, and AWS JSON error envelopes.
use Smithy\Protocol\Aws\RestJsonClientProtocol; $protocol = new RestJsonClientProtocol($service);
AWS Rest XML
RestXmlClientProtocol implements aws.protocols#restXml with Smithy HTTP bindings,
the XML codec, and AWS XML error envelopes.
use Smithy\Protocol\Aws\RestXmlClientProtocol; $protocol = new RestXmlClientProtocol($service);
AWS Query
AwsQueryClientProtocol implements aws.protocols#awsQuery with form URL-encoded
requests and XML responses.
use Smithy\Protocol\Aws\AwsQueryClientProtocol; $protocol = new AwsQueryClientProtocol($service);
The protocol reads the service version from the service and sends it with the operation action in every request body.
EC2 Query
Ec2QueryClientProtocol implements aws.protocols#ec2Query with EC2-specific form
member names, flattened lists, and XML response wrappers.
use Smithy\Protocol\Aws\Ec2QueryClientProtocol; $protocol = new Ec2QueryClientProtocol($service);
The protocol reads the service version from the service.
Dependencies
This package depends on smithy/codec, smithy/core, smithy/http,
smithy/protocol, psr/http-message, ext-libxml, and ext-simplexml.