Skip to content

PHP dumper docker extension allows you to call well-known 'dd' and 'dump' functions in your application and see the output in a clean and structured format directly within the extension.

Notifications You must be signed in to change notification settings

artifision/php-dumper-docker-extension

Repository files navigation

PHP Dumper

This is a Docker extension that allows you to dump variables in your PHP code using the well-known Symfony VarDumper component.

PHP Dumper

Installation

Install Docker Desktop if you don't have it already.

Run the following command in your terminal to install the extension or install it from the Docker Desktop Extensions marketplace:

docker extension install artifision/php-dumper-docker-extension:latest

Run the following command in your project to install the VarDumper component if you don't have it already:

If you are using Symfony or Laravel, you don't need to install the component as it is already installed by default.

composer require --dev symfony/var-dumper

Configuration

You need to tell your PHP application to forward the dump data to the extension:

  • If you have a .env file in your project, add the following line to it:

    VAR_DUMPER_FORMAT=server
  • If you don't use a .env file, you can add the following line at the beginning of your PHP code:

    $_SERVER['VAR_DUMPER_FORMAT'] = 'server';
  • If your project is on a Docker container, you need to add the following line to your docker-compose.yml file under your PHP service configuration to allow the container to communicate with the local machine:

    extra_hosts:
        - "host.docker.internal:host-gateway"

    In addition to the line above, you need to add the following line to your .env file or a PHP file as mentioned above:

    VAR_DUMPER_FORMAT=server
    VAR_DUMPER_SERVER=host.docker.internal:9912

Usage

Open the PHP Dumper extension in Docker Desktop and simply call dump() or dd() function in your PHP code and the result will be displayed in the extension.

Caution

The extension uses ports 9912 and 9913 to communicate with your PHP application. Make sure these ports are not used by other applications on your machine.

Troubleshooting

  • If you are unable to see the dump data in the extension, try opening the following URL in your browser to see if the extension is able to receive the data:

    http://localhost:9913/dump
    
  • If you still see the dump data in the browser but not in the extension, try updating the symfony/var-dumper package to the latest version:

    composer update symfony/var-dumper

Clean up

To remove the extension:

docker extension rm artifision/php-dumper-docker-extension:latest

License

The PHP Dumper is open-sourced software licensed under the MIT license.

Credits

Logo by Smashicons from Flaticon.

About

PHP dumper docker extension allows you to call well-known 'dd' and 'dump' functions in your application and see the output in a clean and structured format directly within the extension.

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published