Home > CMS Tutorial > WordPress > body text

How to set up an atom environment for WordPress development

藏色散人
Release: 2021-02-01 11:54:21
forward
2388 people have browsed it

The following column WordPress Tutorial will introduce to you how to set up an atom environment for WordPress development. I hope it will be helpful to friends in need!

How to set up an atom environment for WordPress development

WordPress is really a weird project. Many of its coding standards are so different from PSR2. For example, general PHP projects require spaces to replace the TAB key, but only WordPress alone requires that the TAB key itself be used for indentation, etc. So much so that an atom environment must be set up specifically for its development.

Find and install the project-manager plug-in in atom. With it, we can create our own special environment for the WordPress project alone.

According to the documentation, after selecting Save Project in the menu, it will create a ~/.atom/projects.cson file, which contains the path of your project and other basic information.

In the root directory of your project, create a file named project.cson with the following content:

settings:
  "*":
    "linter-phpcs.codeStandardOrConfigFile": "WordPress"
  ".html.php.text":
    "editor.tabType": "hard"
Copy after login

The third line means: Only perform WordPress calibration on this project test.

Lines 4 and 5 mean: Only perform hard TAB on php files.

In this way, all your other PHP projects are still verified using the PSR2 standard and are soft TABs, that is, TABs will be converted to spaces, but only the PHP projects in this project are hard TABs, and other files For example, JS, etc. are still soft TAB.

Regarding the installation of WordPress coding standards, please refer to the previous article: https://segmentfault.com/a/11...

New method

Project Management in Atom is not easy to use. In the end, I used the editorconfig plus phpcs method to set it up:

editorconfig

First of all, in Create an .editorconfig file in the root directory of the project:

root = true
[*.php]
indent_style = tab
[*.scss]
indent_style = space
indent_size = 2
Copy after login

This stipulates that the indentation method of php files must use the TAB key. Note: Atom must change the indentation mode to Auto, otherwise the settings in editorconfig will not work.

phpcs.xml

Then, create a phpcs.xml file in the project root directory:

<?xml version="1.0"?>
<ruleset name="Custom Standard">
 <rule ref="WordPress"/>
</ruleset>
Copy after login

Here, we tell phpcs, this Project will use WordPress verification.

Related recommendations: "atom tutorial"

The above is the detailed content of How to set up an atom environment for WordPress development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!