Skip to content

Commit 75fa548

Browse files
authored
Adds the PHP linting instructions to the language level README. (#6486)
1 parent eb578a0 commit 75fa548

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

php/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ To install dependencies, run `composer install` (https://getcomposer.org) before
4646
Many examples come with a `Runner.php` file to abstract the logic of the example from running the code.
4747
From any example directory with a `Runner.php` file, run the example with `php Runner.php`.
4848

49+
50+
## Linting and formatting
51+
We use [phpcs](https://github.com/PHPCSStandards/PHP_CodeSniffer/) to keep this code consistently formatted and styled.
52+
To contribute PHP code to this project, please refer to the following installation and usage steps.
53+
54+
### Using PHPCS
55+
56+
From the `/php` directory, make sure all dependencies are installed at that level with `composer install`.
57+
58+
Then, the linter can be run with
59+
`vendor/bin/phpcs --standard=../.github/linters/phpcs.xml --extensions=php --ignore=vendor /path/to/lint`
60+
61+
Replace `/path/to/lint` with the directory you wish to check.
62+
63+
Simple errors can be automatically fixed using phpcbf:
64+
`vendor/bin/phpcbf --standard=../.github/linters/phpcs.xml --extensions=php --ignore=vendor example_code/dynamodb/`
65+
4966
## Tests
5067
**Note**: Running the tests might result in charges to your AWS account.
5168

php/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require-dev": {
77
"phpunit/phpunit": "^9.5",
88
"php-mock/php-mock-phpunit": "*",
9-
"squizlabs/php_codesniffer": "3.*"
9+
"squizlabs/php_codesniffer": "*"
1010
},
1111
"autoload": {
1212
"psr-0": {

php/composer.lock

+38-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)