Skip to main content
Gitpod supports PHP right out of the box, but more advanced features such as debugging can be configured, so here is how to do it!
There is also an awesome community project that utilizes ddev with Gitpod and makes things much easier. Be sure to check it out first from below! https://ddev.github.io/ddev-gitpod-launcher/ With it, you can run XDebug out of the box, change PHP versions on the fly, and much more!

Example Repositories

Switching PHP versions

Gitpod installs PHP from Ondřej Surý’s PPA in here. The default version should be set to PHP8. But let’s say you want to switch to PHP7.4, follow along! At first, add a .gitpod.Dockerfile file on your repo with the following content in it:
Secondly, reference the above Dockerfile in your .gitpod.yml configuration file, like so:
Now you can See it in action on a new workspace

Debugging PHP in Gitpod

The PHP Debug extension allows debugging PHP applications from within Gitpod. To get this extension for your project, you must do two things: First, you must create a .gitpod.Dockerfile for your repository:
Second, reference the above Dockerfile in a .gitpod.yml file, and then also install the extension, like so:
Now you can See it in action on a new workspace Later, you can head over to Run and Debug on the left hand side and have fun debugging PHP! You can also create a launch.json file. Finally, here is a full example repository containing the complete Gitpod PHP debug configuration described above. You can try it by clicking here: Open in Gitpod

PECL Package Manager

Gitpod’s default workspace image also comes with the PECL package manager pre-installed. To install packages with it, you must use sudo pecl install <EXTENSION> in your repository’s .gitpod.Dockerfile, e.g. like so:
where <EXTENSION> is the PHP extension you want to install, e.g. xdebug.

Setting GitHub token to Composer

Some composer plugins like symfony/flex does direct API call against GitHub to fetch additional information. These unauthenticated requests will be rate-limited and may fail your task steps. To fix this behavior we can use the default credential-helper to obtain a GitHub Token and configure composer properly

Further Reading