Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems.

Bạn đang xem: Php and html formatting in vs code formatting in vscode, code formatting

With a large collection of extensions for many programming languages, VS Code can be customized to lớn serve a wide variety of development needs. In this guide, you’ll learn how to lớn set up Visual Studio Code for working on PHP projects.



To follow this guide, you’ll need to tải về and install the appropriate version of Visual Studio Code for your operating system.

The instructions in this guide were validated on an Ubuntu 20.04 desktop computer, but they should work seamlessly in all operating systems that are supported by VS Code. Please note, though, that keyboard shortcut keys may need khổng lồ be slightly modified for compatibility with MacOS systems.

Step 1 — Installing VS Code PHP Extensions for Extra Support

Right after installation, VS Code already recognizes PHP code and helps with syntax highlighting, basic debugging, and code indentation. These features are suitable for quick edits or when working with individual PHP scripts. Working in larger projects, though, can become difficult without more context around the code & how each tệp tin interacts và integrates within the larger project.

There are a number of VS Code extensions that can help speed up your productivity when working on PHP projects. In this guide, we’ll install and set up PHP Intelephense, a popular PHP extension for VS Code that provides several advanced features such as improved code completion, better navigation between components, rich information tooltips on mouse hover, code tự động hóa formatting, & real time error reporting based on static code analysis.

Open the extensions tab by clicking on the last icon on the left thực đơn bar, or by pressing CTRL + SHIFT + X. This will bring up a sidebar menu with a search box and a list of popular or recommended extensions. Type “php” or “intelephense” to lớn locate the PHP Intelephense extension. Click on the Install button to install & enable the extension.


Once installation is complete, Intelephense’s official documentation recommends that you disable the built-in PHP Language Features extension that comes with VS Code.

To disable this extension, type
builtin php in the Extensions search box to lớn locate the built-in PHP extensions. Then click on the settings icon for the PHP Language Features extension, and click the Disable option in the drop-down menu.


If you have any files xuất hiện in VS Code, you’ll need to reload the editor khổng lồ apply the changes.

You can install other extensions by following the same process described for the PHP Intelephense extension, but be aware that some extensions will require additional software lớn be installed on your system. Check the extension documentation to lớn make sure you have requirements set appropriately.

Step 2 — Importing or Creating a New PHP Project

To import an existing PHP project into VS Code, click on the first icon on the left thực đơn bar or type CTRL + SHIFT + E to lớn access the file explorer. Click the Open Folder button & select your project’s directory. In case you are creating a new project, you can create a new folder and select that as your project directory.

Xem thêm:


The explorer window will now show the project’s directory tree, giving you quick access lớn files and directories on your project.

Step 3 — Customizing Theme and Editor fonts (Optional)

Although not necessary, it is often a good idea to customize the appearance of your editor khổng lồ make it more comfortable to lớn use in the longer term. As a developer you may spend several hours every day looking at an IDE such as VS Code, and for that reason it’s important lớn make sure the editor phông has an appropriate size, and the contrast is enough for good readability without tiring your eyes too quickly.

You may want to experiment with different themes và fonts in order to lớn find a custom cài đặt that works well for you.

Changing VS Code Theme

VS Code comes with a few different themes that allow you lớn change the colors used in the editor interface và in the code highlighting. Both dark & light styles are included by default.

Go lớn File -> Preferences -> Color Theme or type CTRL + K + T to select a different theme for VS Code.


You can also install theme extensions to further customize VS Code’s appearance. If you tìm kiếm for theme within the extensions tab (CTRL + SHIFT + X), you’ll find several theme extensions in different styles và colors, including màu sắc schemes ported from other popular editors & platforms.

Adjusting the Font

Although the default VS Code font settings will be good enough for many users, you may want lớn adjust the kích thước and the type of the editor phông for increased readability.

If you would lượt thích to modify the font form size or change lớn another type, you can go to File -> Preferences -> Settings, then choose Text Editor on the left menu. Then, click on Font in the submenu that opens up. That section contains phông family and kích cỡ settings which you can tweak as preferred.


The changes are immediately saved and applied to lớn all current open files.


Visual Studio Code is a lightweight yet powerful code editor that can be customized khổng lồ suit the needs of most developers. In this guide, you learned how to lớn install & configure the PHP Intelephense extension for extra support while working on PHP projects, how to import & create new projects within VS Code, and how khổng lồ customize the editor appearance for a more comfortable coding experience.

For more tutorials on Visual Studio Code, kiểm tra our VS Code tag page. If you’d like to learn more about PHP development, you can refer lớn our How lớn Code in PHP series for an introduction khổng lồ the language, & our PHP tag page for more PHP tutorials.

Thanks for learning with the Community. Check out our offerings for compute, storage, networking, and managed databases.