Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haruncpi/wordpress-cs
WordPress Coding Standard Setup Guideline
https://github.com/haruncpi/wordpress-cs
coding-standard phpcs wordpress wpcs
Last synced: about 1 month ago
JSON representation
WordPress Coding Standard Setup Guideline
- Host: GitHub
- URL: https://github.com/haruncpi/wordpress-cs
- Owner: haruncpi
- Created: 2022-09-17T04:28:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-08T04:26:35.000Z (over 2 years ago)
- Last Synced: 2024-11-14T11:31:21.671Z (3 months ago)
- Topics: coding-standard, phpcs, wordpress, wpcs
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WPCS Setup Guideline
### 1. Install composer packages
```
composer global require squizlabs/php_codesniffer
```
```
composer global require wp-coding-standards/wpcs
```
**Installation Test**: Run the below command for checking `phpcs` is installed correctly.```
phpcs -i
```**Problem Fix:** command not found: `phpcs`
To fix this problem, add the `phpcs` path to your PATH variable.
`phpcs` and `phpcbf` installed path.
```
/Users/your_username/.composer/vendor/bin/phpcs
```
```
/Users/your_username/.composer/vendor/bin/phpcbf
```
**[Note]** change `your_username`
### 2. Set WordPress as default coding standard
[Note] change `your_username`
```
phpcs --config-set installed_paths /Users/your_username/.composer/vendor/wp-coding-standards/wpcs
```**Default Standard**
Set default CS```
phpcs --config-set default_standard WordPress
```**Installation Test**
```
phpcs --config-show
```### 3. To check a php file, run
```
phpcs abc.php
```### 4. Run `phpcbf` for automatic fix, run
```
phpcbf abc.php
```[Read about PHP CS for WordPress](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)