Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Feature Request: Implement `__debugInfo()` on `Aws\Command` to prevent massive `var_dump` / log output

Open Beginner friendly
#3,365 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start at Aws\Command and reproduce the example.php scenario that dumps an AwsException containing a command. Implement the requested reduced debug representation for the command, preserving the essential name and data while avoiding recursive handler and API model output. Done means var_dump($e) no longer produces the massive nested output described in the issue.

Written by the indexing model from the issue text.

Description

feature-request needs-triage
Describe the feature

I would like to request implementing the magic method __debugInfo() on Aws\Command (and potentially related internal objects. e.g. Aws\HandlerList) to suppress excessively large outputs when using var_dump(), print_r().

When an exception occurs (e.g. Aws\Exception\AwsException), dumping the exception via var_dump($e) or passing it to certain loggers results in extremely large output.
This is mainly because AwsException holds an instance of Aws\Command, which references heavy nested service handlers and shape definitions.

Use Case
# example.php
require_once __DIR__ . '/vendor/autoload.php';

$s3Client = new Aws\S3\S3Client([/* ... */]);

try {
    $s3Client->getObject([
        'Bucket' => 'test-bucket',
        'Key'    => 'notfound.txt',
    ]);
} catch (Exception $e) {
    var_dump($e);
}

Running the above script produces gigabytes of text output because var_dump recursively traverses all properties inside Command and its associated API models/handlers.
This makes print-debugging almost impossible and can easily overwhelm logging storage/buffers in production or development environments.

$ php example.php > out.txt
$ ls -l | grep out.txt
-rwxr-xr-x 1 user group 26626988124 Oct  2 13:52 out.txt
Proposed Solution

Implement __debugInfo() in Aws\Command so that only essential debug details (such as command name and passed arguments) are returned during inspection.

By defining __debugInfo(), PHP will use this reduced array for var_dump() / print_r() instead of recursively dumping all internal property references.

for example:

namespace Aws;

class Command implements CommandInterface
{
    // ...

    public function __debugInfo(): array
    {
        return [
            'name' => $this->name,
            'data' => $this->data,
        ];
    }
}

Then, Output is below:

$ php example.php > out.txt
$ ls -l | grep out.txt
-rwxr-xr-x 1 user group 782744 Oct  2 13:57 out.txt
Other Information

No response

Acknowledgements
  • I may be able to implement this feature request
  • This feature might incur a breaking change
SDK version used

3.399.0

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.3.31/Rocky Linux 10.2

Dominant language
PHP
Stars
6.2k
Forks
1.3k
Avg merge
17h 23m
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-sdk-php

All issues in aws/aws-sdk-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.