Setting Up Stackdriver Debugger for PHP

App Engine standard environment

The Stackdriver Debugger agent for PHP is not supported in App Engine standard environment yet.

App Engine flexible environment

  1. Add the Google Cloud PHP Debugger package to your composer.json file:

    composer require google/cloud-debugger
    
  2. Add the Stackdriver Debugger PHP extension via your composer.json file:

    composer require ext-stackdriver_debugger
    
  3. Enable Stackdriver integrations in your app.yaml file:

    runtime_config:
      enable_stackdriver_integration: true
    
  4. Enable the agent.

    Add the following code to your app as early in the request as possible:

    use Google\Cloud\Debugger\Agent;
    
    $agent = new Agent(['sourceRoot' => realpath('/app')]);
    

The debugger is now ready for use with your app.

Kubernetes Engine

  1. Make sure your cluster is created with one of the following access scopes:

    • https://www.googleapis.com/auth/cloud-platform
    • https://www.googleapis.com/auth/cloud_debugger

    Example:

    gcloud container clusters create example-cluster-name \
        --scopes https://www.googleapis.com/auth/cloud-platform
    
  2. Follow the instructions for Compute Engine.

Compute Engine

  1. Make sure your Compute Engine instances are created with the access scope option Allow full access to all Cloud APIs, or have one of the following access scopes:

    • https://www.googleapis.com/auth/cloud-platform
    • https://www.googleapis.com/auth/cloud_debugger
  2. Add the Google Cloud PHP Debugger package to your composer.json file:

    composer require google/cloud-debugger
    
  3. Install the stackdriver_debugger extension (if using containers, install to the image) from PECL:

    pecl install stackdriver_debugger-alpha
    
  4. Configure a daemon to run the Stackdriver Debugger daemon process:

    php /[YOUR-APP-PATH]/vendor/bin/google-cloud-debugger -s /[YOUR-APP-PATH]
    
  5. Enable the agent.

    Add the following code to your app as early in the request as possible:

    use Google\Cloud\Debugger\Agent;
    
    $agent = new Agent(['sourceRoot' => realpath('/[YOUR-APP-PATH]')]);
    

The debugger is now ready for use with your app.

Local and Elsewhere

  1. Add the Google Cloud PHP Debugger package to your composer.json file:

    composer require google/cloud-debugger
    
  2. Install the stackdriver_debugger extension from PECL:

    pecl install stackdriver_debugger-alpha
    
  3. Run the Stackdriver Debugger daemon process:

    php /[YOUR-APP-PATH]/vendor/bin/google-cloud-debugger -s /[YOUR-APP-PATH]
    
  4. Enable the agent.

    Add the following code to your app as early in the request as possible:

    use Google\Cloud\Debugger\Agent;
    
    $agent = new Agent(['sourceRoot' => realpath('/[YOUR-APP-PATH]')]);
    

The debugger is now ready for use with your app.

The Debug page in the GCP Console can display local source files, without upload, for local development. See Selecting Source Code Manually.

Send feedback about...

Stackdriver Debugger Documentation