Skip to content

Commit

Permalink
Use a composer plugin to register the standard
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Sep 20, 2023
1 parent e9b46ea commit 6d8a941
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ To use within your Magento 2 project you can use:
composer require --dev magento/magento-coding-standard
```

Due to security, when installed this way the Magento standard for phpcs cannot be added automatically.
You can achieve this by adding the following to your project's `composer.json`:

```json
"scripts": {
"post-install-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
],
"post-update-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
]
}
```

### Installation for development

You can install Magento Coding Standard by cloning this GitHub repo:
Expand Down Expand Up @@ -122,7 +108,7 @@ The rules from rector that are applied are set inside the config file: `rector.p
The option `--dry-run` displays errors found, but code is not automatically fixed.

To run rector for `magento` projects you need to:
- Specify the magento path and the autoload file for the magento project:
- Specify the magento path and the autoload file for the magento project:
```bash
vendor/bin/rector process MAGENTO_PATH --dry-run --autoload-file MAGENTO_AUTOLOAD_FILE
```
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"version": "32",
"require": {
"php": "~8.1.0 || ~8.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2 || ^1.0",
"webonyx/graphql-php": "^15.0",
"ext-simplexml": "*",
"ext-dom": "*",
Expand Down Expand Up @@ -36,13 +37,9 @@
"Magento2Framework\\": "Magento2Framework/"
}
},
"scripts": {
"post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../phpcompatibility/php-compatibility/PHPCompatibility",
"post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../phpcompatibility/php-compatibility/PHPCompatibility"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d8a941

Please sign in to comment.