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. Install the stackdriver_debugger extension from PECL:

    pecl install stackdriver_debugger-alpha
    

    If your php.ini file does not include extension=stackdriver_debugger.so after running this step, add it manually.

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

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

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

    runtime_config:
      enable_stackdriver_integration: true
    
  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('/app')]);
    

The debugger is now ready for use with your app.

GKE

  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. Install the stackdriver_debugger extension (if using containers, install to the image) from PECL:

    pecl install stackdriver_debugger-alpha
    
  3. Add the Google Cloud PHP Debugger package to your composer.json file:

    composer require google/cloud-debugger
    
  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. Install the stackdriver_debugger extension from PECL:

    pecl install stackdriver_debugger-alpha
    
  2. Add the Google Cloud PHP Debugger package to your composer.json file:

    composer require google/cloud-debugger
    
  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.

Was this page helpful? Let us know how we did:

Send feedback about...

Stackdriver Debugger Documentation