|
1 | 1 | # Exercism PHP Track |
2 | 2 |
|
3 | | - |
4 | | -[](https://www.codacy.com/app/borgogelli/php?utm_source=github.com&utm_medium=referral&utm_content=borgogelli/php&utm_campaign=Badge_Grade) |
5 | | - |
6 | 3 | Exercism exercises in PHP |
7 | 4 |
|
| 5 | +Follow these instructions to contribute to the PHP track. |
| 6 | +To solve the exercises, head to the [PHP track][exercism-track-home] and check the [documentation][exercism-track-installation]. |
| 7 | + |
8 | 8 | ## Install Dependencies |
9 | 9 |
|
10 | | -### All dependencies |
| 10 | +The following system dependencies are required: |
11 | 11 |
|
12 | | -```shell |
13 | | -> ./bin/install.sh |
14 | | -``` |
| 12 | +- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer]. |
| 13 | +- [`bash` shell][gnu-bash] |
15 | 14 |
|
16 | | -### Only tests dependencies |
| 15 | +Run the following commands to get started with this project: |
17 | 16 |
|
18 | 17 | ```shell |
19 | | -> ./bin/install-phpunit-9.sh |
| 18 | +bin/fetch-configlet # The official tool for managing Exercism language track repositories |
| 19 | +composer install # Required dependencies to develop this track |
20 | 20 | ``` |
21 | 21 |
|
22 | | -### Only style-check dependencies |
| 22 | +## Running Exercism resources management |
23 | 23 |
|
24 | | -```shell |
25 | | -> ./bin/install-phpcs.sh |
26 | | -``` |
| 24 | +`bin/configlet` is a tool to manage exercism resources in this track. |
| 25 | +See [Building Exercism docs][exercism-configlet]. |
27 | 26 |
|
28 | 27 | ## Running Unit Test Suite |
29 | 28 |
|
30 | | -### PHPUnit 9 |
| 29 | +The tests are run with PHPUnit. A shell loop injecting `exemplar.php` is provided to ease testing. |
| 30 | + |
| 31 | +Execute the following command to run the tests: |
31 | 32 |
|
32 | 33 | ```shell |
33 | | -> PHPUNIT_BIN="./bin/phpunit-9.phar" ./bin/test.sh |
| 34 | +composer test:run |
34 | 35 | ``` |
35 | 36 |
|
36 | 37 | ## Running Style Checker |
37 | 38 |
|
38 | | -### PSR-12 rules |
| 39 | +This project use a slightly [modified][local-file-phpcs-config] version of [PSR-12]. |
| 40 | +Use the following commands to apply code style: |
39 | 41 |
|
40 | 42 | ```shell |
41 | | -> PHPCS_BIN="./bin/phpcs.phar" PHPCS_RULES="./phpcs-php.xml" ./bin/lint.sh |
| 43 | +composer lint:check # Checks the files against the code style rules |
| 44 | +composer lint:fix # Automatically fix codestyle issues |
42 | 45 | ``` |
43 | 46 |
|
44 | 47 | ## Contributing |
45 | 48 |
|
46 | | -- Read the documentation at [Exercism][docs]. |
47 | | -- Follow the [PSR-12] coding style (PHP uses a slightly [modified] version of [PSR-12]). |
| 49 | +- Read the documentation at [Exercism][exercism-docs]. |
| 50 | +- Follow the [PSR-12] coding style (Exercisms PHP track uses a slightly [modified][local-file-phpcs-config] version of [PSR-12]). |
48 | 51 | - CI is run on all pull requests, it must pass the required checks for merge. |
49 | | - |
| 52 | +- CI is running all tests on PHP 8.0 to PHP 8.2 |
| 53 | + |
| 54 | +[exercism-configlet]: https://exercism.org/docs/building/configlet |
| 55 | +[exercism-docs]: https://exercism.org/docs |
| 56 | +[exercism-track-home]: https://exercism.org/docs/tracks/php |
| 57 | +[exercism-track-installation]: https://exercism.org/docs/tracks/php/installation |
| 58 | +[exercism-track-installation-composer]: https://exercism.org/docs/tracks/php/installation#h-install-composer |
| 59 | +[gnu-bash]: https://www.gnu.org/software/bash/ |
| 60 | +[local-file-phpcs-config]: phpcs.xml |
50 | 61 | [psr-12]: https://www.php-fig.org/psr/psr-12 |
51 | | -[docs]: https://exercism.org/docs |
52 | | -[@group annotation]: https://phpunit.de/manual/4.1/en/appendixes.annotations.html#appendixes.annotations.group |
53 | | -[modified]: phpcs-php.xml |
|
0 commit comments