|
1 | | -# Alpine PHP |
| 1 | +# Alpine PHP |
2 | 2 | <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> |
3 | 3 | [](#contributors-) |
4 | 4 | <!-- ALL-CONTRIBUTORS-BADGE:END --> |
5 | 5 |
|
6 | | -Repository of https://hub.docker.com/r/jorge07/alpine-php |
| 6 | +[](https://github.com/jorge07/alpine-php/actions/workflows/pr.yaml) |
| 7 | + |
| 8 | +[](https://hub.docker.com/r/jorge07/alpine-php) |
| 9 | +[](https://ghcr.io/jorge07/alpine-php) |
7 | 10 |
|
8 | | -[](https://github.com/jorge07/alpine-php/actions/workflows/pr.yaml)  |
| 11 | +Lightweight PHP-FPM Docker images based on Alpine Linux — under 40MB. |
9 | 12 |
|
10 | | -Small PHP Docker images based on Alpine [<40MB]. |
| 13 | +Kept up to date with [active PHP releases](https://www.php.net/supported-versions.php). Weekly automated rebuilds pick up Alpine security patches. |
11 | 14 |
|
12 | | -Up to date with [active releases](https://www.php.net/supported-versions.php) and a place for older unmaintained images. |
| 15 | +--- |
13 | 16 |
|
14 | | -## Documentation |
| 17 | +## Images |
15 | 18 |
|
16 | | -[Read about Documentation and see some examples here](https://github.com/jorge07/alpine-php/tree/master/doc/README.md) |
| 19 | +| Tag | PHP | Alpine | Arch | |
| 20 | +|---|---|---|---| |
| 21 | +| `8.4` / `8.4-dev` | 8.4.x | edge | amd64, arm64, arm/v7, arm/v8 | |
| 22 | +| `8.3` / `8.3-dev` | 8.3.x | 3.20 | amd64, arm64, arm/v7, arm/v8 | |
| 23 | +| `8.2` / `8.2-dev` | 8.2.x | 3.21 | amd64, arm64, arm/v7, arm/v8 | |
| 24 | +| `8.1` / `8.1-dev` | 8.1.x | 3.19 | amd64, arm64, arm/v7, arm/v8 | |
17 | 25 |
|
18 | | -## Images |
| 26 | +Available on [Docker Hub](https://hub.docker.com/r/jorge07/alpine-php) and [GHCR](https://ghcr.io/jorge07/alpine-php). |
| 27 | + |
| 28 | +### Deprecated (available but unmaintained) |
| 29 | + |
| 30 | +`8.0` · `7.4` · `7.3` · `7.2` · `7.1` · `5.6` |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Quick start |
| 35 | + |
| 36 | +```sh |
| 37 | +# Production image — PHP-FPM on port 9000 |
| 38 | +docker run -d --name php -p 9000:9000 -v $PWD:/app jorge07/alpine-php:8.3 |
| 39 | + |
| 40 | +# Dev image — PHP-FPM + Xdebug + Composer + SSH |
| 41 | +docker run -d --name php-dev \ |
| 42 | + -p 2244:22 \ |
| 43 | + -p 9003:9003 \ |
| 44 | + -v $PWD:/app \ |
| 45 | + jorge07/alpine-php:8.3-dev |
| 46 | +``` |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Dev Container (VS Code) |
| 51 | + |
| 52 | +The repo ships a `.devcontainer/devcontainer.json` for use with [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) or [GitHub Codespaces](https://github.com/features/codespaces). |
| 53 | + |
| 54 | +### Get started in 3 steps |
| 55 | + |
| 56 | +1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) in VS Code |
| 57 | +2. Open your project folder |
| 58 | +3. Click **Reopen in Container** (or run `Dev Containers: Reopen in Container` from the command palette) |
| 59 | + |
| 60 | +VS Code will pull `jorge07/alpine-php:8.3-dev`, mount your project at `/app`, and pre-install: |
| 61 | +- [PHP Debug](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) (Xdebug 3 integration) |
| 62 | +- [Intelephense](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client) (PHP language server) |
| 63 | + |
| 64 | +### Xdebug launch config |
| 65 | + |
| 66 | +Add `.vscode/launch.json` to your project: |
| 67 | + |
| 68 | +```json |
| 69 | +{ |
| 70 | + "version": "0.2.0", |
| 71 | + "configurations": [ |
| 72 | + { |
| 73 | + "name": "Listen for Xdebug", |
| 74 | + "type": "php", |
| 75 | + "request": "launch", |
| 76 | + "port": 9003, |
| 77 | + "pathMappings": { |
| 78 | + "/app": "${workspaceFolder}" |
| 79 | + } |
| 80 | + } |
| 81 | + ] |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +Set breakpoints, press **F5**, and trigger a request. For CLI scripts: |
| 86 | + |
| 87 | +```sh |
| 88 | +docker exec php-dev sh -c "XDEBUG_SESSION=1 php /app/script.php" |
| 89 | +``` |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## Dev images — manual setup |
| 94 | + |
| 95 | +Dev images add Xdebug, Composer, SSH, and Supervisor on top of the production image. |
| 96 | + |
| 97 | +### PHPStorm (SSH remote interpreter) |
19 | 98 |
|
20 | | -- [8.3](https://github.com/jorge07/alpine-php/blob/master/8.3/Dockerfile) |
21 | | -- [8.2](https://github.com/jorge07/alpine-php/blob/master/8.2/Dockerfile) |
22 | | -- [8.1](https://github.com/jorge07/alpine-php/blob/master/8.1/Dockerfile) |
| 99 | +```sh |
| 100 | +docker run -d --name php-dev -p 2244:22 -p 9003:9003 -v $PWD:/app jorge07/alpine-php:8.3-dev |
| 101 | +``` |
| 102 | + |
| 103 | +**Languages & Frameworks → PHP → Add → SSH Credentials** |
23 | 104 |
|
24 | | -# Deprecated but available images |
| 105 | +| Field | Value | |
| 106 | +|---|---| |
| 107 | +| Host | `localhost` | |
| 108 | +| Port | `2244` | |
| 109 | +| User | `root` | |
| 110 | +| Password | `root` | |
| 111 | +| PHP executable | `/usr/bin/php` | |
25 | 112 |
|
26 | | -- [8.0](https://github.com/jorge07/alpine-php/blob/master/8.0/Dockerfile) |
27 | | -- [7.4](https://github.com/jorge07/alpine-php/blob/master/7.4/Dockerfile) |
28 | | -- [7.3](https://github.com/jorge07/alpine-php/blob/master/7.3/Dockerfile) |
29 | | -- [7.2](https://github.com/jorge07/alpine-php/blob/master/7.2/Dockerfile) |
30 | | -- [7.1](https://github.com/jorge07/alpine-php/blob/master/7.1/Dockerfile) |
31 | | -- [5.6](https://github.com/jorge07/alpine-php/blob/master/5.6/Dockerfile) |
| 113 | +**Path mappings:** `<project root>` → `/app` |
32 | 114 |
|
33 | | -## Usage: |
| 115 | +**Debug → Xdebug port:** `9003` |
| 116 | + |
| 117 | +### Custom SSH credentials |
34 | 118 |
|
35 | 119 | ```sh |
36 | | -docker run -d --name dev -p 2323:22 -v $PWD:/app jorge07/alpine-php:8.3-dev |
| 120 | +docker build \ |
| 121 | + --build-arg USER=myuser \ |
| 122 | + --build-arg PASSWORD=mypass \ |
| 123 | + --target dev -t myapp:dev \ |
| 124 | + -f 8.3/Dockerfile 8.3/ |
37 | 125 | ``` |
38 | 126 |
|
39 | | -> To make xdebug config easier for all environments there's a custom ENVVAR you can define: `XDEBUG_CLIENT_HOST`. |
40 | | -> Example: XDEBUG_CLIENT_HOST=docker.for.mac for OSX, XDEBUG_CLIENT_HOST=docker.for.windows for Windows users and Linux users and Remote interpreters by SSH can leave it empty. |
| 127 | +### Xdebug 3 — key settings |
| 128 | + |
| 129 | +| Setting | Value | |
| 130 | +|---|---| |
| 131 | +| Port | `9003` (changed from 9000 in Xdebug 2) | |
| 132 | +| Trigger | `XDEBUG_SESSION=1` env var | |
| 133 | +| Mode | `debug` (set in image, trigger-based) | |
| 134 | + |
| 135 | +> **Migrating from Xdebug 2?** See the [IDE integration guide](doc/IDE.md) for a full comparison table and PHPStorm setup walkthrough. |
| 136 | +
|
| 137 | +--- |
| 138 | + |
| 139 | +## PHP Extensions |
| 140 | + |
| 141 | +All images include: |
41 | 142 |
|
42 | | -> SSH is only for IDE integration to use container as remote interpreter |
| 143 | +`bcmath` · `ctype` · `curl` · `dom` · `exif` · `fileinfo` · `gd` · `iconv` · `intl` · `mbstring` · `opcache` · `openssl` · `pcntl` · `pdo` · `pdo_mysql` · `pdo_pgsql` · `phar` · `session` · `simplexml` · `sodium` · `tokenizer` · `xml` · `xmlreader` · `xsl` · `zip` · `zlib` · `apcu` |
43 | 144 |
|
44 | | -## Dev Dockerfiles |
| 145 | +Dev images additionally include: `xdebug` · `pear` |
45 | 146 |
|
46 | | -Dev images extend the standard ones and add some tools for development and CI like, composer, xdebug, etc... |
| 147 | +--- |
47 | 148 |
|
48 | 149 | ## Contributors ✨ |
49 | 150 |
|
|
0 commit comments