How to debug PHP application in Google Cloud Workstations

155 Views Asked by At

Currently I use Google Cloud Shell Editor as my chosen IDE. I like the code editor based on VS Code, and also like the persistent 5GB home directory. This allows me to install PHP on the home directory, which in turn means that I can run my app using the command php -S localhost:8080

Recently I heard about Google Cloud Workstations which provides multi-IDE support, including a version of VS Code called "Code-OSS". I would like to start using the Cloud Workstations as my IDE, but the one thing holding me back is PHP. I don't know how to debug a PHP application using Google Cloud Workstations which run in the browser.

How can I run my PHP applications in Google Cloud Workstations which run in the browser?

2

There are 2 best solutions below

3
On BEST ANSWER

If you're familiar with VS Code, the look and feel is very similar. I've managed to run php -S localhost:8080 using Google Workstations by updating and upgrading my packages first:

sudo apt-get update
sudo apt-get upgrade

Then I install PHP afterwards:

sudo apt-get install php

Right now I'm using the latest PHP version (PHO 7.4.30) but you can use your preferred version using this link as your reference.

Let me know if this worked out for you.

1
On

I’ve created a Dockerfile using Google base image with Code-OSS and installing all the libraries that I need, including nginx on port 8080.

In this way I can both use the IDE and run the application on the same workstation and it works like a charm.