Skip to content

Commit f2fefce

Browse files
authored
Ease contribution with Devcontainer (#1041)
1 parent 9be2b3d commit f2fefce

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM mcr.microsoft.com/devcontainers/php:4-8.4-bookworm
2+
3+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends jq \
5+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
6+
7+
# ds is pinned to v1, since v2 (the only version building against PHP 8.4 via
8+
# PECL/docker-php-ext-install) dropped Vector/Deque/Stack/Queue/PriorityQueue.
9+
RUN curl -L -o install-php-extensions \
10+
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
11+
&& chmod +x install-php-extensions \
12+
&& ./install-php-extensions gmp ds-^1@stable intl \
13+
&& rm install-php-extensions

.devcontainer/devcontainer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Exercism PHP",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"containerEnv": {
7+
"XDEBUG_MODE": "off"
8+
},
9+
"postCreateCommand": "composer install",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"bmewburn.vscode-intelephense-client"
14+
],
15+
"settings": {
16+
"php.suggest.basic": false
17+
}
18+
}
19+
}
20+
}

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,26 @@ Exercism exercises in PHP
55
Follow these instructions to contribute to the PHP track.
66
To solve the exercises, head to the [PHP track][exercism-track-home] and check the [documentation][exercism-track-installation].
77

8+
## Quick Start with Dev Containers
9+
10+
This repo includes a [dev container](.devcontainer) that provides PHP 8.4, Composer, `jq` and all other dependencies out of the box.
11+
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.
12+
813
## Install Dependencies
914

1015
The following system dependencies are required:
1116

1217
- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer].
1318
- [`bash` shell][gnu-bash].
14-
- PHP V8.4+ CLI.
19+
- PHP V8.4+ CLI, with the following extensions:
20+
- `ds` (V1.x)
21+
- `intl`
22+
- 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`
1523
- An active Internet connection for installing required tools / composer packages.
1624
- [`jq`][jq], if you change the difficulty or add a practice exercise.
1725

26+
The [dev container](.devcontainer) already provides all of the above.
27+
1828
Run the following command to get started with this project:
1929

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

0 commit comments

Comments
 (0)