Skip to content
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
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/devcontainers/php:4-8.4-bookworm

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends jq \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# ds is pinned to v1, since v2 (the only version building against PHP 8.4 via
# PECL/docker-php-ext-install) dropped Vector/Deque/Stack/Queue/PriorityQueue.
RUN curl -L -o install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
&& chmod +x install-php-extensions \
&& ./install-php-extensions gmp ds-^1@stable intl \
&& rm install-php-extensions
Comment on lines +7 to +13

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead upgrade the test runner and everything to V2 ? Or would you prefer doing this in the php 8.5 upgrade ?

Note that even if they were removed, new alternatives were provided https://github.com/php-ds/ext-ds/releases/tag/v2.0.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ds is not a requirement the track has or I introduced. It was "requested" by neenjaw (the maintainer before I came in) as a useful computer-sciency data type extension used in community solutions.

I did not upgrade it because of the breaking interface changes. I'd rather "discuss" (if there is anyone discussing that with me anyways) to drop it completely with the PHP 8.5 upgrade - it's not there for fluency in PHP, but for academic knowledge and production grade programming.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See forum for follow-up.

20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Exercism PHP",
"build": {
"dockerfile": "Dockerfile"
},
"containerEnv": {
"XDEBUG_MODE": "off"
},
"postCreateCommand": "composer install",
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client"
],
"settings": {
"php.suggest.basic": false
}
}
}
}
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ Exercism exercises in PHP
Follow these instructions to contribute to the PHP track.
To solve the exercises, head to the [PHP track][exercism-track-home] and check the [documentation][exercism-track-installation].

## Quick Start with Dev Containers

This repo includes a [dev container](.devcontainer) that provides PHP 8.4, Composer, `jq` and all other dependencies out of the box.
Open the repo in [VS Code][vscode-devcontainers] (or [GitHub Codespaces][github-codespaces]) and select "Reopen in Container" - `composer install` runs automatically once it starts.

## Install Dependencies

The following system dependencies are required:

- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer].
- [`bash` shell][gnu-bash].
- PHP V8.4+ CLI.
- PHP V8.4+ CLI, with the following extensions:
- `ds` (V1.x)
- `intl`
- Default modules: `Core`, `ctype`, `date`, `dom`, `fileinfo`, `filter`, `hash`, `iconv`, `json`, `libxml`, `mbstring`, `pcre`, `random`, `Reflection`, `SimpleXML`, `sodium`, `SPL`, `standard`, `tokenizer`, `xml`, `xmlreader`, `xmlwriter`, `zlib`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just mention ext-* requirements? It does not look relevant to mention "Core", "ctype", "date"...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same list we added to the test-runner. It is the same list, that shall be added to the PHP track docs. A beginner who wants to start learning can use php -m to check the installed modules using these names. With composers ext-* notation they have to translate the names to composers style, have composer installed at all and filter away many more names from the composer output than from php -m.

To us, ctype et al. do not seem relevant. In PHP documentation, the functions and classes are organized by them. So I can use the ctype functions, study them, try them out in my solutions etc. It's a common question: What functions could I use at all? What's my "search space"?

- An active Internet connection for installing required tools / composer packages.
- [`jq`][jq], if you change the difficulty or add a practice exercise.

The [dev container](.devcontainer) already provides all of the above.

Run the following command to get started with this project:

```shell
Expand Down Expand Up @@ -98,7 +108,9 @@ Run `bin/order-exercises.sh` when you set the exercise difficulty to a sensible
[exercism-track-home]: https://exercism.org/docs/tracks/php
[exercism-track-installation]: https://exercism.org/docs/tracks/php/installation
[exercism-track-installation-composer]: https://exercism.org/docs/tracks/php/installation#h-install-composer
[github-codespaces]: https://docs.github.com/en/codespaces/overview
[gnu-bash]: https://www.gnu.org/software/bash/
[jq]: https://jqlang.org/
[local-file-phpcs-config]: phpcs.xml
[psr-12]: https://www.php-fig.org/psr/psr-12
[jq]: https://jqlang.org/
[vscode-devcontainers]: https://code.visualstudio.com/docs/devcontainers/containers
Loading