Skip to content

Change bin directory #56

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

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ php:
- 7.1
install: composer install --no-interaction --prefer-source
script:
- bin/phpunit
- bin/phpcs --standard=Magento Magento/ --extensions=php
- vendor/bin/phpunit
- vendor/bin/phpcs --standard=Magento Magento/ --extensions=php
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@

A set of Magento rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) tool.

### Installation
For development puposes you can install Magento Coding Standard by cloning this GitHub repo
#### Installation within a Magento 2 site
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`:
````
"scripts": {
"post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/",
"post-update-cmd": "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
```
$ git clone [email protected]:magento/magento-coding-standard.git
$ cd magento-coding-standard
Expand All @@ -13,17 +27,16 @@ It is possible also to install a standalone application via [Composer](https://g
```
$ composer create-project magento/magento-coding-standard --stability=dev magento-coding-standard
```
Or require `magento/magento-coding-standard` inside your project using `composer require` command.

#### Verify installation
Command should return the list of installed coding standards including Magento.
```
$ bin/phpcs -i
$ vendor/bin/phpcs -i
```
### Usage
Once installed, you can run `phpcs` from the command-line to analyse your code `MyAwesomeExtension`
```
$ bin/phpcs --standard=Magento app/code/MyAwesomeExtension
$ vendor/bin/phpcs --standard=Magento app/code/MyAwesomeExtension
```
## Where to contribute
- Documentation of existing rules. See [ExtDN PHP CodeSniffer rules for Magento 2](https://github.com/extdn/extdn-phpcs) as a good example.
Expand All @@ -43,7 +56,7 @@ $ bin/phpcs --standard=Magento app/code/MyAwesomeExtension
All rules should be covered by unit tests. Each `Test.php` class should be accompanied by a `Test.inc` file to allow for unit testing based upon the PHP CodeSniffer parent class `AbstractSniffUnitTest`.
You can verify your code by running
```
$ bin/phpunit
$ vendor/bin/phpunit
```

## License
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"config": {
"bin-dir": "bin"
},
"scripts": {
"post-install-cmd": "bin/phpcs --config-set installed_paths ../../..",
"post-update-cmd": "bin/phpcs --config-set installed_paths ../../.."
"post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..",
"post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../.."
}
}