From b8f3d43cdf65b19b5cb5764563f544b4626de31d Mon Sep 17 00:00:00 2001 From: Robert Egginton Date: Fri, 8 Mar 2019 11:41:15 +0100 Subject: [PATCH 1/4] Change bin directory --- .travis.yml | 2 +- README.md | 2 +- composer.json | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b87566c..2fc006a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ php: install: composer install --no-interaction --prefer-source script: - bin/phpunit - - bin/phpcs --standard=Magento Magento/ --extensions=php + - vendor/bin/phpcs --standard=Magento Magento/ --extensions=php diff --git a/README.md b/README.md index 15dd894b..96dd032d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Or require `magento/magento-coding-standard` inside your project using `compose #### 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` diff --git a/composer.json b/composer.json index 6c27724c..9cd0b1ae 100644 --- a/composer.json +++ b/composer.json @@ -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 ../../.." } } From f71798ae65c685fb528b72f38112ff7410be28cb Mon Sep 17 00:00:00 2001 From: Robert Egginton Date: Fri, 8 Mar 2019 11:57:04 +0100 Subject: [PATCH 2/4] Updated paths for phpunit and README.md --- .travis.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2fc006a2..bd7a6a1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,5 @@ php: - 7.1 install: composer install --no-interaction --prefer-source script: - - bin/phpunit + - vendor/bin/phpunit - vendor/bin/phpcs --standard=Magento Magento/ --extensions=php diff --git a/README.md b/README.md index 96dd032d..f0ba78ba 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ $ 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. @@ -43,7 +43,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 From 13afa9264ac4aa2d21e5a54dc69d3ae4b25073a1 Mon Sep 17 00:00:00 2001 From: Robert Egginton Date: Fri, 8 Mar 2019 12:24:11 +0100 Subject: [PATCH 3/4] Added install path for composer installation on site --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9cd0b1ae..915770c4 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "scripts": { - "post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..", - "post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../.." + "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/,../../.." } } From c713e6cfb3eeb293db266bb00abcf54aa49308ca Mon Sep 17 00:00:00 2001 From: Robert Egginton Date: Fri, 8 Mar 2019 14:33:09 +0100 Subject: [PATCH 4/4] Replaced additional installed_path with README.md instruction --- README.md | 19 ++++++++++++++++--- composer.json | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f0ba78ba..30840574 100644 --- a/README.md +++ b/README.md @@ -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 git@github.com:magento/magento-coding-standard.git $ cd magento-coding-standard @@ -13,7 +27,6 @@ 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. diff --git a/composer.json b/composer.json index 915770c4..9cd0b1ae 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "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/,../../.." + "post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..", + "post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../.." } }