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

青灯夜游
Release: 2023-04-10 10:10:01
forward
3482 people have browsed it

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:

Lets 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

Lets take a look at how VSCode configures the Laradock container and PHPCS plug-in

##Select our

workspace Container:

Lets 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:

Lets 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
Copy after login

Install the

phpcs plug-in in VSCode:

Lets 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"
Copy after login
in setting.json

where

phpcs path:

Lets 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:

Lets 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:

Lets 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!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template