Home>Article>Backend Development> Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

青灯夜游
青灯夜游 forward
2021-07-02 18:32:29 3349browse

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

This article mainly records 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 many tools, we can achieve our goals without any settings.

Open the code from the container

First we must ensure that we have started our container:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Then Start VSCode, use the commandF1, selectRemote Explorer: Focus on Containers View

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

##Select our

workspaceContainer:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

At this time, a new page will be reopened allowing you to select the path where the code is located. After

OK, you can open the code, and The effect of selecting from the local path is the same:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Install the phpcs plug-in

Because the local Laradock is configured with multiple source code projects, it is installed globally.

squizlabs/php_codesniffer, enter the workspace container:

// 进入容器 dc exec workspace bash // 安装插件 composer global require squizlabs/php_codesniffer

Install the

phpcsplug-in in VSCode:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Then follow It can be configured and used. Add:

"phpcs.executablePath": "/root/.composer/vendor/bin/phpcs", "phpcs.standard": "PSR2"
insetting.json

where

phpcspath:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Configuration After that, you can see that our code is not standardized:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

There is an extra space between the original keyword

functionand the method name. After the modification, the prompt disappeared:

Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in

Summary

With the environment, you don’t need to install the required environment locally. , such as PHP, phpcs, etc., you can completely make your computer very "clean". When you are not developing, you can directly close Docker or the container and leave the computer in "office" status. Seamless switching between "Development" and "Administrative Office".

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of Let’s take a look at how VSCode configures the Laradock container and PHPCS plug-in. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete