Moment For Technology

VSCode associates with the Laradock container to configure the PHPCS plug-in

Posted on Sept. 27, 2022, 2:22 p.m. by Lori Lopez
Category: The back-end Tag: php laravel

This article describes how to associate the Laradock container with VSCode, configure and use the container's PHP environment, and some plug-ins, such as PHPCS.

Since VSCode has inherited a lot of tools, we can achieve our goals without much setting up.

Open the code from the container

First we must make sure that we have started our container:

Then launch VSCode, use the F1 command, and select Remote Explorer: Focus on Containers View:

Select our Workspace container:

This will open a new page and allow you to select the path where the code is located. If OK, this will open the code, just as if you had selected it from the local path:

Install the PHPCS plug-in

Because the local Laradock is configured with multiple source code projects, install Squizlabs/PHp_Codesniffer globally and enter the Workspace container:

// Install plug-in Composer global require squizlabs/ php_CodesnifferCopy the code

Install PHPCS plugin in VSCode:

Then you can use the configuration. In setting.json, add:

    "phpcs.executablePath": "/root/.composer/vendor/bin/phpcs"."phpcs.standard": "PSR2"
Copy the code

PHPCS path:

After the configuration, you can see that our code is not canonical:

There is an extra space between the function keyword and the method name. After that, the hint disappears:


With the environment in the local can not install the required environment, such as PHP, PHPCS, etc., can completely make their own computer is very "clean". When not developing, you can directly close Docker or container, leaving the computer in "office" state. "Development" and "administrative office" seamlessly switch.

Next, configure the debug plug-in.

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.