Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About configuring VSCode to interpret php #628

Open
mozgbrasil opened this issue Sep 5, 2019 · 77 comments
Open

About configuring VSCode to interpret php #628

mozgbrasil opened this issue Sep 5, 2019 · 77 comments

Comments

@mozgbrasil
Copy link

About configuring VSCode to interpret php

Hello my friend

Can you help me how to configure VSCode to interpret php

I need to point docker php to VSCode

It is possible ? Can you help me

@robots4life
Copy link

I think it is possible and some people have done it and there is a script somewhere but it would be really cool if someone can come up with a step by step guide and how to get this done with Devilbox.

@mrbig00
Copy link
Contributor

mrbig00 commented Sep 6, 2019

If you are talking about setting up XDebug with devilbox and VSCode: here you go

@stale
Copy link

stale bot commented Nov 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the issue:stale This issue has become stale and is marked for auto-close label Nov 5, 2019
@cytopia cytopia removed the issue:stale This issue has become stale and is marked for auto-close label Nov 17, 2019
@robots4life
Copy link

Screenshot_20191122_091947

@mrbig00 Is this the same as setting up XDebug? I don't think so.

If we simply want VSCode to be able to access PHP inside the Devilbox container, what do we need to do? So regardless of project, just have VSCode "connect" to PHP inside the Devilbox container. How is that done please?

@robots4life
Copy link

@mozgbrasil Did you find a solution? Do you use XDebug or just have PHP be "available" inside VSCode regardless of project?

@mozgbrasil
Copy link
Author

Good Morning

I installed php on the operating system

And due to the operating system apache2 conflict with devilbox I'm using the practice of stopping apache

   sudo service apache2 stop

@robots4life
Copy link

@mozgbrasil

I am using Devilbox and Docker to keep my OS free of Apache, NGINX, PHP, etc.
Of course I could have installed it on the OS and simply connect VSCode to it.

@cytopia I am trying to "connect" PHP from inside the Devilbox container to VSCode on the OS.
What parts in the https://devilbox.readthedocs.io/en/latest/index.html might be able to point me in the right direction?

https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug/linux/vscode.html#configure-php-xdebug-lin-vscode is for XDebug. But what if I just want to "connect" VSCode to PHP in the Devilbox container and not use XDebug?

@cytopia
Copy link
Owner

cytopia commented Nov 22, 2019

if I just want to "connect" VSCode to PHP in the Devilbox container and not use XDebug?

What is the reason or what is this useful for, If I might ask.

@Cipa
Copy link

Cipa commented Nov 22, 2019

Not sure if related but for me, running tools like phpcs (php code fixer), I have them currently pointed at the OS php install which is not really correct. It should be linked to the container in case you are using a different php version than your OS

@robots4life
Copy link

robots4life commented Nov 23, 2019

@cytopia What @Cipa wrote is exactly one of the reasons for example.

Another reason would be to be able to use https://github.com/Automattic/VIP-Coding-Standards or https://github.com/squizlabs/PHP_CodeSniffer.

In fact being able to do that would be truly awesome.

On purpose I am keeping the host OS slim, fast and clean.
Being able to use these tools inside VSCode through Devilbox, oh my, that would be really nice.

@cytopia
Copy link
Owner

cytopia commented Nov 23, 2019

@mozgbrasil @robots4life @Cipa as this is very VSCode specific and I've never used it, I am unfortunately out of any help to you guys. I would suggest to get support directly at the relevant VSCode places:

@cytopia cytopia self-assigned this Nov 23, 2019
@robots4life
Copy link

@cytopia Ok, thank you.

Can you explain, if I wanted to make PHP available outside the Devilbox container, other than through the browser, would I need to open a port or do something similar like change the .env file? Not sure if this applies but what if I wanted to check i.e. the version of PHP inside the Devilbox container but from the host OS in a console. How could I pass such a command to inside the Devilbox container?

Where in the docs can I read up on the concept of making PHP available outside the Devilbox container? I guess this is more Docker specific, but if you have a topic in the docs that you think might be able to help even remotely, please let me know.

Thank you.

@cytopia
Copy link
Owner

cytopia commented Nov 23, 2019

If you are in the Devilbox directory, you can use it as such:

docker-compose exec -T --user devilbox php php -v

@boumanb
Copy link

boumanb commented Nov 25, 2019

Hi @robots4life, I am using the new VS Code Remote Development to accomplish this. Make sure you have one of the following extensions installed ms-vscode-remote.vscode-remote-extensionpack (package containing remote development for SSH, Containers and WSL) or ms-vscode-remote.remote-containers (for remote development in containers).

After installing these extensions all you need is a devcontainer.json file in a .devcontainer folder inside of your workspace. <project>/.devcontainer/devcontainer.json.
In case of Devilbox the file should look like the following:

// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
	// See https://aka.ms/vscode-remote/devcontainer.json for format details.
	"name": "Existing Docker Compose (Extend)",

	// Update the 'dockerComposeFile' list if you have more compose files or use different names.
	// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
	"dockerComposeFile": [
		"../../../../docker-compose.yml" // Point to Devilbox's docker-compose.yml
	],

	// The 'service' property is the name of the service for the container that VS Code should
	// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
	"service": "php", // Name of the service we want to remote to

	// The optional 'workspaceFolder' property is the path VS Code should open by default when
	// connected. This is typically a file mount in .devcontainer/docker-compose.yml
	"workspaceFolder": "/shared/httpd/<project-name>", // For example: /shared/httpd/my-website

	// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
	// "shutdownAction": "none",

	// Uncomment the next line if you want to add in default container specific settings.json values
	// "settings":  { "workbench.colorTheme": "Quiet Light" },

	// Uncomment the next line to run commands after the container is created - for example installing git.
	// "postCreateCommand": "apt-get update && apt-get install -y git",

	// Add the IDs of any extensions you want installed in the array below.
	"extensions": [
            "eamodio.gitlens",
            "felixfbecker.php-debug",
            "felixfbecker.php-intellisense",
            "fterrag.vscode-php-cs-fixer",
            "atlassian.atlascode"
    ],
}

This approach needs Devilbox to be up and running on forehand.

When the extensions are installed AND the devcontainer.json file is present in the appropriate folder VS Code will notify you about that it detected the file (upon reopening the workspace) and that you're able to reopen the project inside of the container.

image

After reopening the project inside of the container you're also able to fire commands inside of the container straight away from VS Code's built-in terminal. For example composer install etc.

image

@cytopia
Copy link
Owner

cytopia commented Nov 25, 2019

@boumanb thanks for the detailed post. One more thing to sort is how to actually make the terminal start up as the devilbox user instead of root. The devilbox user has the same uid/gid as your local user and I suppose you rather want it to issue any commands to keep permissions between inside the Docker container and your host syncronized.

@boumanb
Copy link

boumanb commented Nov 25, 2019

No problem. Glad I can contribute in some way, truly a great project. Glad to see you active again.

You're totally right. It's better to keep these permissions synchronized. However, I've not been able to find a solution for this. VS Code has some documentation on using a different user while developing remotely: https://code.visualstudio.com/docs/remote/containers-advanced#_adding-a-nonroot-user-to-your-dev-container

Apparently when using the approach described above, we have to define the user in the docker-compose.yml (docker-compose.override.yml in our case) like user: "devilbox" although this causes the php service to crash.

php_1      | [INFO] Changing group 'devilbox' gid to: 1000
php_1      | groupmod: Permission denied.
php_1      | groupmod: cannot lock /etc/group; try again later.

@cytopia
Copy link
Owner

cytopia commented Nov 25, 2019

// Uncomment the next line to run commands after the container is created - for example installing git.
// "postCreateCommand": "apt-get update && apt-get install -y git",

Is this probably something where you could do: su - devilbox as a post command?

@boumanb
Copy link

boumanb commented Nov 25, 2019

Normally, yes. But in my case Devilbox is running 24/7 in the background. The // "postCreateCommand": "apt-get update && apt-get install -y git", will only be executed when creating a new remote environment from image, Dockerfile or docker-compose for example. What I tell my VS Code with the configured devcontainer.json is to make use of the pre-existing environment.

@robots4life
Copy link

@boumanb Thank you! I will give all this a try and report back either way.

@boumanb
Copy link

boumanb commented Nov 28, 2019

Great, looking forward to your response!

@robots4life
Copy link

@boumanb

Make sure you have one of the following extensions installed ms-vscode-remote.vscode-remote-extensionpack (package containing remote development for SSH, Containers and WSL) or ms-vscode-remote.remote-containers (for remote development in containers).

My workflow is such that I run node, npm, grunt, sass, etc. locally on the host in the project folder and like to do things like php coding standards or php code sniffer in the container.

First, would you see an advantage in running everything in the container, while having HOST_PATH_HTTPD_DATADIR pointing to a local folder with all my projects? Meaning in those local folders just have the files for the project and have tools etc. in the containers.

At the moment I am fine with having the tools mixed into the project folders. This means I need to have node and npm on the host what sometimes leads to minor issues when updates or different versions are required.

I tried both ways and found that having things local is a bit faster. Would you see another advantage of running all the tools in the containers?

Then I am not sure what package to pick from the two you mention. Like I said I do all the development locally and would only need to run the php tools in the container. What package is better suited for that?

@robots4life
Copy link

robots4life commented Apr 6, 2021

@CamdenGonzalez have you got a way to meet in chat, I have a feeling that could benefit both of us, the long term plan is to add documentation for how to use the available tools in a remote container in VSCode.

If chat is not an option, can you elaborate on how you, if I understand you correct, got xDebug working over the browser and phpcs / php-cs-fixer working locally ?

edit: which php-cs-fixer in the shell does not show me anything for example when doing a fresh start on the Devilbox, so wonder why you have a full path there while I get no output. However which phpcs does show me the same path as you have it.

Also under the devilbox path in bash I just added this phptools.sh file that gets php-cs-fixer working with the https://github.com/junstyle/vscode-php-cs-fixer extension. Feel free to change this as you like, i.e. including a check for the date of the php-cs-fixer-v2.phar last download and only renew it every so often.. it is just a basic example of how I currently set this up.

#! /usr/bin/env bash

# VSCode remote container - php-cs-fixer

# 1. go to /shared/httpd/phptools

cd /shared/httpd/phptools

# 2. remove the current version and download the latest version

rm -rf php-cs-fixer

# 3. download php-cs-fixer into /shared/httpd/phptools

wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer

# 4. give executeable permission to php-cs-fixer

sudo chmod a+x php-cs-fixer

# 5. copy executeable php-cs-fixer to bin /usr/local/bin/ directory

sudo cp /shared/httpd/phptools/php-cs-fixer /usr/local/bin/php-cs-fixer

# 6. add php-cs-fixer to Devilbox's $PATH

PATH=$PATH:/usr/local/bin/php-cs-fixer

# 7. return to /shared/httpd

cd /shared/httpd


# Install PHP coding standards ..

Concerning phpcs and phpcbf I am looking at the following.

  1. https://github.com/valeryan/vscode-phpsab
  2. https://github.com/WordPress/WordPress-Coding-Standards
  3. https://github.com/tommcfarlin/phpcs-wpcs-vscode

WordPress is not the focus here, though figuring out to to get rules, fixing and beautifying going with that might also help with the other standards.

@robots4life
Copy link

How to get SvelteKit working with Devilbox. #797 (comment)

@fkaminski
Copy link

fkaminski commented Jul 8, 2021

Thank you for all these informations!
(Especially the detailed information from @boumanb helped me.)

Possibly this information would also be suitable for the devilbox documentation like:
https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html
(even if it is not a devilbox specific topic)

II will try in any case to take up this approach in our Contao documentation or to extend it ...

@cytopia
Copy link
Owner

cytopia commented Jul 8, 2021

I will try in any case to take up this approach in our Contao documentation or to extend it ...

Cool. Let me know when its in and I can replicate it on the Devilbox documentation as well

@fkaminski
Copy link

Cool. Let me know when its in and I can replicate it on the Devilbox documentation as well

Check.
I will summarize the info and create a PR for the Contao doc. As soon as this is accepted I will let you know...

@fkaminski
Copy link

fkaminski commented Jul 8, 2021

So I don't forget: See:
contao/docs#790

@fkaminski
Copy link

fkaminski commented Jul 11, 2021

Unfortunately, I still have a question.
I had used VSCode with Xdebug, with this "PHP Debug" extension installed locally in VSCode.
Together with the information from the devilbox documentation it worked.

Now I have installed the "Visual Studio Code Remote Development" pack as described here. It works so far.
In the VSCode terminal I am inside the devilbox php container with the user "devilbox". Also e.g. "Intelephense" via this extension works.

But:
Now I have to install in VSCode, analogous to e.g. "Intelephense", also the "PHP Debug" extension in the container itself.
Now unfortunately it does not work anymore. I have tried various entries in the "devilbox\cfg\php-ini-7.4\xdebug.ini" and ".vscode\launch.json".

  • Windows 10 Pro / WSL 2 / current devilbox version (with PHP 7.4).
  • /shared/httpd/demo
  • devilbox/data/www/demo/htdocs
  • https;//demo.loc

Could anyone provide a working configuration/help for Xdebug usage in this environment?
Thanks a lot

@fkaminski
Copy link

fkaminski commented Jul 12, 2021

Addition:
Here is my working configuration when the VSCode "PHP debug" extension is installed locally within VSCode
(analogous to the devilbox documentation):

\devilbox\cfg\php-ini-7.4\xdebug.ini

xdebug.mode               = debug
xdebug.start_with_request = yes

xdebug.remote_handler   = dbgp
xdebug.remote_port      = 9000

xdebug.remote_connect_back = 0 
;from vEthernet (WSL):
xdebug.client_host = 172.19.112.1

xdebug.idekey           = VSCODE
xdebug.remote_log       = /var/log/php/xdebug.log

\devilbox\data\www\demo\.vscode\launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for Xdebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "pathMappings": {"/shared/httpd/demo/htdocs": "${workspaceRoot}/htdocs"}
    }
  ]
}

Hint:
Using Docker via WSL 2:
The entry for "xdebug.client_host" here according to the IPv4 address from "vEthernet (WSL)" (see ipconfig).

Using Docker via VM (Windows 10 Pro / Hyper-V):
The entry for "xdebug.client_host" here corresponding to the IPv4 address from "vEthernet (Default Switch)" (see ipconfig).

@fkaminski
Copy link

fkaminski commented Jul 12, 2021

Now I need help with the procedure using "Visual Studio Code Remote Development" :
VSCode is asking me for relaunch according to this:

\devilbox\data\www\demo\.devcontainer\devcontainer.json

{
  "name": "Existing Docker Compose (Extend)",
  "dockerComposeFile": [
    "../../../../docker-compose.yml" 
  ],
  "service": "php", 
  "workspaceFolder": "/shared/httpd/demo", 
  "remoteUser": "devilbox",
}

As already mentioned it works then regarding using VSCode terminal (inside the devilbox php container with the user "devilbox") or using the "Intelephense" extension for example.

The existing extension "PHP Debug" is now grayed out with the option to install it within the PHP container.
After installation, I am now trying to set a breakpoint and debug without any other changes:

Result:
_Error: listen EADDRINUSE: address already in use :::9000

I then tried different entries in "xdebug.ini" and "launch.json".
Unfortunately without further success.
Grateful for your suggestions ...

@masiorama
Copy link

I am stuck as @fkaminski is.
From my previous comments I totally switched to WSL2 (ubuntu + docker), hoping for the best.
I am trying to make things to work, but still no success.
Plus, I am unhappy with the devcontainer.json bringing up all the services, but at the moment I haven't find the correct way to ups only a few selected services (like you can do via docker-compose up php httpd).

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the issue:stale This issue has become stale and is marked for auto-close label Mar 2, 2022
@robots4life
Copy link

Does anyone know how to install Vercel, Netlify and GitHub CLI to the Devilbox so they work from VS Code and are possibly kept installed between shut down and start (not when removing containers) ?

@stale stale bot removed the issue:stale This issue has become stale and is marked for auto-close label Mar 24, 2022
@robots4life
Copy link

robots4life commented Mar 24, 2022

https://devilbox.readthedocs.io/en/latest/autostart/custom-scripts-globally.html#custom-scripts-globally

In /devilbox/autostart I have created a file clis.sh with following content.

#! /usr/bin/env bash

# run this script
# chmod +x clis.sh
# ./clis.sh

npm install vercel -g

npm install netlify-cli -g

Remember to chmod +x clis.sh inside /devilbox/autostart so the script can be executed.
This will install Vercel and Netlify CLI globally in Devilbox and persist the installation as long as the clis.sh fils is kept inside /devilbox/autostart.

Per docs, i.e.

# Install grunt as devilbox user
# su -c "npm install grunt" -l devilbox

asks for a password that I don't know and that is not the host password.

But the CLIs are installed as the devilbox user since in devcontainer.json I have the line "remoteUser": "devilbox",.

https://github.com/cli/cli/blob/trunk/docs/install_linux.md

The GitHub CLI has a different approach to install and since git is pretty much the only tool I have on the host I am happy installing the GitHub CLI on the host as well.

@patrict
Copy link

patrict commented Mar 11, 2023

Ive been using Devilbox for all of 2 hours, so Im not sure if I came up with a really simple way to solve this, or a terrible way, you be the judge, but it seems to be working for me 😂

All I did was :

  1. Log into the php container using the shell.sh
  2. ln -s /usr/local/bin/php php

This creates a symlink to the php binary, which is now also available on the host machine under your devilbox/data/www folder. I then
4. Edit VS Code settings.json
5. Set the path of the php.validate.executablePath attribute

Phenomenal project @cytopia thanks a mill, Im loving it so far.

@patrict
Copy link

patrict commented Mar 12, 2023

I subsequently found the following warning here in the documentation:

Do not create any symlinks inside your project directories that go outside the data dir. Anything which is outside this directory is not mounted into the container.

Considering Im doing the opposite, and adding the symlink inside the container, Im not sure if this warning is applicable, since my solution seems to work for me, and the PHP binary is available from my host system 🤷‍♂️

Im still learning docker, but it seems the most correct solution would be to create a read-only mount point to the appropriate target in the container, in the same way as the project folder is mounted. This would be to expose the PHP binaries (or any other desired binaries for that matter) more safely via a dedicated mounted directory?

@robots4life
Copy link

@patrict what are you trying to achieve ? Do you want VS Code to "connect" to Devilbox and work with Devilbox inside VS Code ? Happy to give you a quick "up and running" tour on how to get that working with VS Code, if that is what you want to do.

@patrict
Copy link

patrict commented Mar 12, 2023

@patrict what are you trying to achieve ? Do you want VS Code to "connect" to Devilbox and work with Devilbox inside VS Code ? Happy to give you a quick "up and running" tour on how to get that working with VS Code, if that is what you want to do.

@robots4life thanks a mill, appreciate it 😄 I have my data directory setup outside of the Devilbox directory now and can work on my projects, so that seems to be working correctly.

What Im trying to achieve:
Some VS Code PHP plugins require a PHP binary in order to function - an example of this is PHP Intelephense. Much like many of the other posters on this thread, I do not want to install PHP on my host, so I was looking for a way to make the Devilbox PHP container's binary available to the host system, so that I could configure the PHP Intelephense plugin in VS Code to use that binary.

@masiorama
Copy link

masiorama commented Mar 13, 2023

@patrict are you on Linux or Windows? On Windows (+ WSL2) I was able to make things to work, while I have no direct experience on native Linux.

@patrict
Copy link

patrict commented Mar 13, 2023

@patrict are you on Linux or Windows? On Windows (+ WSL2) I was able to make things to work, while I have direct experience on native Linux.

@masiorama option C - Mac M1 😄

Just to clarify, my symlink did work, so I was just sharing my solution for comment, in case anyone had a better/alternative method

@BWBama85
Copy link

BWBama85 commented May 4, 2023

Hi @patrict

Thanks for your info you posted. It may be pointing me in the correct direction but I am wanting to take this a step further.

My setup:

Fedora 38
Devilbox v3.0.0-beta-0.3 (2023-01-02)

My startup script:

#!/usr/bin/env sh

cd /home/$USER/.devilbox/

case "$1" in
  restart)
    echo "Stopping services..."
    docker compose stop
    echo "Services stopped."

    echo "Removing containers..."
    docker compose rm -f
    echo "Containers removed."

    echo "Starting services..."
    docker compose up -d php php81 php74 httpd mysql bind elastic logstash kibana redis
    echo "Services started."
    ;;
  stop)
    echo "Stopping services..."
    docker compose stop
    echo "Services stopped."

    echo "Removing containers..."
    docker compose rm -f
    echo "Containers removed."
    ;;
  *)
    echo "Usage: $0 {restart|stop}"
    exit 1
    ;;
esac

My default PHP is 8.2 and as you can see I am also loading PHP 7.4 and 8.1

In VSCode I want to take advantage of workspaces for each project and be able to set the interpreter for PHP to the PHP version that that workspace uses.

This is something that is easy to do in vscode per workspace via the settings.

Based on your symlink, would it be possible to enter into each php docker container and symlink each php docker container like this:

PHP 8.2: ln -s /usr/local/bin/php php
PHP 8.1: ln -s /usr/local/bin/php php81
PHP 7.4: ln -s /usr/local/bin/php php74

Then in vscode settings.json set:

php.validate.executablePath="php"
php.validate.executablePath="php81"
php.validate.executablePath="php74"

Depending on the workspace?

@BWBama85
Copy link

BWBama85 commented May 5, 2023

Hmm, it does not seem to work for me. What I did:

Using VSCode Docker extension, I attached the devilbox/php-fpm:8.1-work-0.150 container to a shell.

Ran ln -s /usr/local/bin/php php81
ls shows php81 symlink in /shared/httpd/

On Fedora host machine:
cd /home/brent/Development/www/
ls shows php81

php81 -v does not work.

Screenshot from 2023-05-04 21-21-22
Screenshot from 2023-05-04 21-23-02

Edit: I wonder if it is because I created the symlink as root? Let me try to figure out how to get vscode docker extension to attach as devilbox

Attaching it as root, running su devilbox and then creating the symlink also does not work. Still says command not found.

@BWBama85
Copy link

BWBama85 commented May 5, 2023

So I have the symlink working as long as I am inside the container:

[email protected] in /shared/httpd $ ln -s /usr/local/bin/php /shared/httpd/php81
[email protected] in /shared/httpd $ /shared/httpd/php81 -v
PHP 8.1.14 (cli) (built: Jan  8 2023 00:49:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.14, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans

However, outside the container it still fails:

[brent@fedora www]$ ls -lha
total 4.0K
drwxr-xr-x. 1 brent brent 24 May  4 23:02 .
drwxr-xr-x. 1 brent brent 26 May  4 05:54 ..
lrwxrwxrwx. 1 brent brent 18 May  4 23:02 php81 -> /usr/local/bin/php
drwxr-xr-x. 1 brent brent 30 May  4 06:59 xenforo
[brent@fedora www]$ /home/brent/Development/www/php81 -v
bash: /home/brent/Development/www/php81: No such file or directory

I am guessing I am missing something though not sure how @patrict got it working unless it is something specific to MacOS.

@ghost
Copy link

ghost commented Feb 9, 2024

Hello,

I'm using Google Translate, so I apologize in advance for any writing errors.

To solve this problem, simply create a file called php in the root directory of your project and insert this code:

#!/bin/bash
docker exec -it devilbox php $@

Then make it executable:

~$ chmod +x php

And in VSCode settings, assign this value:

"php.validate.executablePath": "./php",

CREDITS: How to setup VSCode with PHP inside docker

@ghost
Copy link

ghost commented Feb 15, 2024

I just recorded a video explaining how to solve this problem and I even added a bonus that helps start shell.sh automatically when opening VSCode.

LINK: https://youtu.be/rWt4xQTSBAE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests