Skip to content

Instantly share code, notes, and snippets.

@ChristianOellers
Last active August 18, 2023 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristianOellers/02d84e5cd20b25380273feb14ac8add7 to your computer and use it in GitHub Desktop.
Save ChristianOellers/02d84e5cd20b25380273feb14ac8add7 to your computer and use it in GitHub Desktop.
VS Code - PHP in Docker - Editor/IDE language support + linting
#!/bin/bash
docker exec -i --user=111:222 $(docker ps -q) /usr/bin/php "$@"
# Get PHP executable from container and send any argument to it.
#
# Assumptions
# - Calls the current container (docker ps -q).
# - Assumes PHP path exists in container as shown.
#
# Steps to do
# 1. Copy this 'php' file into a folder (here `./vscode`)
# 2. Make this file executable: (sudo) chmod +x ./php
# 3. Get user ID/primary group ID and update the script (id -u | id - g)
# 4. Set VS Code global setting: "php.validate.executablePath": "./.vscode/php"
#
# - @see https://luiscoutinh.medium.com/how-to-set-php-path-to-docker-container-115f363e4b3d
# - @see https://www.webdeveloperpal.com/2022/02/08/how-to-setup-vscode-with-php-inside-docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment