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:293462browse

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 command F1, select Remote Explorer: Focus on Containers View

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

##Select our

workspace Container:

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

phpcs plug-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"
in setting.json

where

phpcs path:

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

function and 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