Exercism exercises in PHP
Follow these instructions to contribute to the PHP track. To solve the exercises, head to the PHP track and check the documentation.
The following system dependencies are required:
composer
, as recommended in the PHP track installation docs.bash
shell.- PHP V8.3+ CLI.
- An active Internet connection for installing required tools / composer packages.
Run the following command to get started with this project:
composer install # Required dependencies to develop this track
bin/configlet
is the official tool for managing Exercism language track repositories.
See Building Exercism docs.
For convenience, you can use composer configlet:fmt
to fix formatting issues in the Exercism track files.
This is included in composer ci
to run the CI checks locally.
The tests are run with PHPUnit. A shell loop injecting exemplar.php
is provided to ease testing.
Execute the following command to run the tests:
composer test:run
This is included in composer ci
to run the CI checks locally.
This project uses a slightly modified version of PSR-12. Use the following commands to apply code style:
composer lint:check # Checks the files against the code style rules
composer lint:fix # Automatically fix code style issues
The lint:check
is included in composer ci
to run the CI checks locally.
- Read the documentation at Exercism.
- Follow the PSR-12 coding style (Exercisms PHP track uses a slightly modified version of PSR-12).
- Run
composer ci
to run CI checks locally before pushing. - CI is run on all pull requests, it must pass the required checks for merge.
- CI is running all tests on PHP 8.0 to PHP 8.2 for Linux, Windows and MacOS.
Use bin/configlet create --practice-exercise <slug>
to create the exercism resources required.
This provides you with the directories and files in exercises/practice/<slug>
.
Look into tests.toml
for which test cases not to implement / generate and mark them with include = false
.
Test generator MVP used like this:
composer -d contribution/generator install
contribution/generator/bin/console app:create-tests '<slug>'
composer lint:fix