Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

INsReady/docker-vscode-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Visual Studio Code for PHP

This docker image packages Visual Studio Code (vscode) with a curated list of extensions for PHP development. The goal of this image is to offer an easier, faster and free IDE, comparing to PhpStorm.

With this image, you don't need to install an "IDE" anymore, you simply run a Docker command, which will launch the vscode, creates the PHP enviroment, and then remove itself when you are done working.

Demo GIF

How to use

Launch:

To launch the "IDE" and set the current folder as the root of your application:

$ docker run -ti --rm --privileged -v /tmp/.X11-unix:/tmp/.X11-unix -v "$PWD":/var/www/html -e DISPLAY=unix$DISPLAY --device /dev/dri --name vscode --net="host" insready/vscode-php

You can set up bash alias for the command above, for example:

nano ~/.bashrc

alias phpcode='docker run -ti --rm --privileged -v /tmp/.X11-unix:/tmp/.X11-unix -v "$PWD":/var/www/html -e DISPLAY=unix$DISPLAY --device /dev/dri --name vscode --net="host" insready/vscode-php'

source ~/.bashrc

Once you set up the alias above, you can simply launch your "IDE" with simple command phpcode.

Stop:

To stop the container and auto-remove it: Just use Ctrl+C

Use with other Docker image:

This image would work well with insready/drupal-dev, Xdebug remote debugging will simply work out of box.

Configure Xdebug to work

This image makes assumption that the default remote server file path is at /var/www/html/. If this indeed is your remote file path, for example, you use insready/drupal-dev for setting up your Drupal develppment enviroment, then you do not need additional configuration. Otherwise, you need to create a mapping between your remote file path, and the file path inside this container, which defaults to /var/www/html/.

To create a file path mapping between remote and local file system, you have to set the localSourceRoot and serverSourceRoot settings in your launch.json, for example:

"serverSourceRoot": "/var/www/html/",
"localSourceRoot": "${cwd}"

More documentation on this bit configuration can be fund here.

List of vscode extensions included

Known issues

  • When you close the vscode UI, the container doesn't stop automatically. Therefore, you need to use Ctrl+C to stop the container therefore to remove it.
  • This image has only been tested on Linux. The --net="host" might not work on Mac, therefore it needs one more step tweek to get Xdebug work out of box.

Contributing

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.

About

Visual Studio Code in a container for PHP/Drupal development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published