Skip to content

#108 Integrate vscode and PhpStorm #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,59 @@ You can easily use the code quality checkers on your CI (CircleCi/Jenkins/GitLab
```
./vendor/bin/grumphp run --no-ansi --no-interaction
```

## IDE Integration (optional)

### Prerequisites

Minimally [Code Quality 2.2.1](https://github.com/wunderio/code-quality/releases/tag/2.2.1) is needed because it contains the WunderAll ruleset that groups all Wunder rulesets.

#### Ubuntu
To install the necessary PHP components without Apache:
```
sudo apt install php-cli php-tokenizer
```

#### macOS
1. Install Homebrew if you don't have it installed already (see instructions on https://brew.sh/)
2. Install PHP with Homebrew
```
brew install php
```

### Configuration

#### Visual Studio Code

1. Install the [Drupal extension](https://marketplace.visualstudio.com/items?itemName=Stanislav.vscode-drupal).
2. Open the Drupal extension configuration.
3. Find "Drupal > Phpcs: Args" and "Drupal > Phpcbf: Args".
4. Click "Edit in settings.json" and add:

```json
{
"drupal.phpcs.args": [
"--standard=WunderAll"
],
"drupal.phpcbf.args": [
"--standard=WunderAll"
]
}
```

PHPCS usage Example in Visual Studio Code:
![PHPCS Usage Example in VSC](https://user-images.githubusercontent.com/11972062/221161739-cabcd4b5-800d-4d5b-8071-9324bf2bcc08.gif)

#### PhpStorm

Open settings and look for PHP_Codesniffer. Make sure these settings are the same:
![PhpStorm settings PHPCS 1/2](https://www.upload.ee/image/16969201/2024-08-14_15-59.png)

Check the paths and validate:
![PhpStorm settings PHPCS 2/2](https://www.upload.ee/image/16969203/2024-08-14_16-01.png)

Warnings are underlined and you can choose to fix them by right clicking:
![How to fix 1/2](https://www.upload.ee/image/16969207/2024-08-14_16-03.png)

Choose the "PHP Code Beautifier and Fixer: fix the whole file"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkirsman Where's this option selectable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you see it here on the screenshot https://github.com/wunderio/code-quality/blob/ad3b9a56d5ff46c10e94e1ab5d3fb7e86004d8a4/README.md#ide-integration-optional ? Isn't that in your editor? It's under right click menu.

@TomiMikola

![How to fix 2/2](https://www.upload.ee/image/16969210/2024-08-14_16-04.png)