docker-php-extensions-knowledge

Docker PHP extensions knowledge base. Provides installation patterns for common extensions, build dependency management, and PECL usage.

59 stars

Best use case

docker-php-extensions-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Docker PHP extensions knowledge base. Provides installation patterns for common extensions, build dependency management, and PECL usage.

Teams using docker-php-extensions-knowledge should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/docker-php-extensions-knowledge/SKILL.md --create-dirs "https://raw.githubusercontent.com/dykyi-roman/awesome-claude-code/main/skills/docker-php-extensions-knowledge/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/docker-php-extensions-knowledge/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How docker-php-extensions-knowledge Compares

Feature / Agentdocker-php-extensions-knowledgeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Docker PHP extensions knowledge base. Provides installation patterns for common extensions, build dependency management, and PECL usage.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Docker PHP Extensions Knowledge Base

Patterns for installing, building, and managing PHP extensions in Docker containers.

## Extension Categories

| Category | Extensions | Purpose |
|----------|-----------|---------|
| **Core** | opcache, intl, mbstring, bcmath | Performance, i18n, math |
| **Database** | pdo_pgsql, pdo_mysql, pgsql, mysqli | Database connectivity |
| **Cache** | redis, apcu, memcached | Caching layers |
| **Crypto** | sodium, openssl | Encryption, hashing |
| **Image** | gd, imagick | Image processing |
| **Archive** | zip, zlib, bz2 | Compression |
| **Message** | amqp, pcntl | Queues, process control |
| **Debug** | xdebug, pcov | Debugging, coverage |
| **Serialization** | igbinary, msgpack | Fast serialization |

## Installation Methods

### Method 1: docker-php-ext-install (Built-in Extensions)

```dockerfile
# Extensions bundled with PHP source
RUN docker-php-ext-install -j$(nproc) \
    opcache \
    intl \
    pdo_pgsql \
    pdo_mysql \
    zip \
    bcmath \
    pcntl \
    sockets
```

### Method 2: docker-php-ext-configure + install

```dockerfile
# Extensions requiring configuration
RUN docker-php-ext-configure gd \
        --with-freetype \
        --with-jpeg \
        --with-webp \
    && docker-php-ext-install -j$(nproc) gd
```

### Method 3: PECL Install

```dockerfile
# Extensions from PECL repository
RUN pecl install redis-6.1.0 apcu-5.1.24 igbinary-3.2.16 \
    && docker-php-ext-enable redis apcu igbinary
```

### Method 4: Manual Compilation

```dockerfile
# For extensions not in PECL or needing custom patches
RUN curl -fsSL https://github.com/example/ext/archive/v1.0.tar.gz | tar xz \
    && cd ext-1.0 \
    && phpize \
    && ./configure \
    && make -j$(nproc) \
    && make install \
    && docker-php-ext-enable ext
```

## Alpine vs Debian Build Dependencies

| Extension | Alpine Packages | Debian Packages |
|-----------|----------------|-----------------|
| intl | `icu-dev` | `libicu-dev` |
| pdo_pgsql | `libpq-dev` | `libpq-dev` |
| pdo_mysql | (none) | (none) |
| gd | `freetype-dev libjpeg-turbo-dev libpng-dev libwebp-dev` | `libfreetype6-dev libjpeg62-turbo-dev libpng-dev libwebp-dev` |
| zip | `libzip-dev` | `libzip-dev` |
| imagick | `imagemagick-dev` | `libmagickwand-dev` |
| amqp | `rabbitmq-c-dev` | `librabbitmq-dev` |
| memcached | `libmemcached-dev zlib-dev` | `libmemcached-dev zlib1g-dev` |
| sodium | `libsodium-dev` | `libsodium-dev` |
| bz2 | `bzip2-dev` | `libbz2-dev` |
| xsl | `libxslt-dev` | `libxslt1-dev` |
| ldap | `openldap-dev` | `libldap2-dev` |
| gmp | `gmp-dev` | `libgmp-dev` |
| imap | `imap-dev krb5-dev` | `libc-client-dev libkrb5-dev` |

## Runtime vs Build Dependencies Pattern

```dockerfile
FROM php:8.4-fpm-alpine AS production

# 1. Install build dependencies (virtual package for easy removal)
RUN apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        icu-dev \
        libpq-dev \
        libzip-dev \
        freetype-dev \
        libjpeg-turbo-dev \
        libpng-dev \
        rabbitmq-c-dev \
    \
# 2. Install and configure extensions
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) \
        intl \
        pdo_pgsql \
        zip \
        gd \
        opcache \
        bcmath \
        pcntl \
        sockets \
    \
# 3. Install PECL extensions
    && pecl install redis apcu amqp igbinary \
    && docker-php-ext-enable redis apcu amqp igbinary \
    \
# 4. Remove build dependencies (keep runtime libs)
    && apk del .build-deps

# 5. Install runtime-only libraries
RUN apk add --no-cache \
    icu-libs \
    libpq \
    libzip \
    freetype \
    libjpeg-turbo \
    libpng \
    rabbitmq-c
```

## Extension Builder Stage Pattern

```dockerfile
# Dedicated stage for compiling extensions (reusable across images)
FROM php:8.4-fpm-alpine AS ext-builder

RUN apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        icu-dev \
        libpq-dev \
        libzip-dev \
    && docker-php-ext-install -j$(nproc) intl pdo_pgsql zip opcache bcmath \
    && pecl install redis apcu \
    && docker-php-ext-enable redis apcu \
    && apk del .build-deps

# Production stage copies only compiled artifacts
FROM php:8.4-fpm-alpine AS production

COPY --from=ext-builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
COPY --from=ext-builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/

RUN apk add --no-cache icu-libs libpq libzip
```

## Framework Extension Combinations

### Symfony Stack

```dockerfile
RUN docker-php-ext-install -j$(nproc) \
    intl \           # Translation, validation, routing
    pdo_pgsql \      # Doctrine DBAL (PostgreSQL)
    opcache \        # Performance
    zip \            # Composer, file handling
    bcmath \         # Precise math (money)
    pcntl \          # Messenger async workers
    sockets          # Messenger AMQP transport

RUN pecl install redis apcu amqp \
    && docker-php-ext-enable redis apcu amqp
```

### Laravel Stack

```dockerfile
RUN docker-php-ext-install -j$(nproc) \
    pdo_mysql \      # Eloquent (MySQL)
    opcache \        # Performance
    zip \            # File handling
    bcmath \         # Precise math
    pcntl \          # Horizon workers
    exif             # Image metadata

RUN pecl install redis igbinary \
    && docker-php-ext-enable redis igbinary
```

### API Platform / High-Load

```dockerfile
RUN docker-php-ext-install -j$(nproc) \
    intl \
    pdo_pgsql \
    opcache \
    bcmath \
    pcntl \
    sockets

RUN pecl install redis apcu amqp igbinary msgpack \
    && docker-php-ext-enable redis apcu amqp igbinary msgpack
```

## OPcache Configuration for Production

```ini
; /usr/local/etc/php/conf.d/opcache.ini
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
opcache.save_comments=1
opcache.jit=tracing
opcache.jit_buffer_size=128M
```

```dockerfile
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
```

## Troubleshooting

| Issue | Cause | Solution |
|-------|-------|----------|
| `cannot find -licu` | Missing icu-dev | `apk add icu-dev` or `apt install libicu-dev` |
| `pecl install fails` | Missing $PHPIZE_DEPS | `apk add $PHPIZE_DEPS` |
| Extension loads but segfaults | Alpine musl incompatibility | Switch to Debian base |
| `Class 'Redis' not found` | Extension not enabled | `docker-php-ext-enable redis` |
| `iconv(): Wrong encoding` | Alpine musl iconv | Install `gnu-libiconv` |
| Slow builds | Sequential compilation | Use `-j$(nproc)` and BuildKit cache |

## References

For the full extensions matrix with all dependencies, see `references/extensions-matrix.md`.
For base image selection, see `docker-base-images-knowledge`.

Related Skills

yii-knowledge

59
from dykyi-roman/awesome-claude-code

Yii framework knowledge base. Provides Yii3 modular architecture, DDD integration, PSR-7/PSR-15 compliance, persistence, DI, security (RBAC, auth), event system (PSR-14), queue/jobs, infrastructure components (cache, rate limiter, HTTP client), testing, and antipatterns for Yii PHP projects.

testing-knowledge

59
from dykyi-roman/awesome-claude-code

Testing knowledge base for PHP 8.4 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

task-progress-knowledge

59
from dykyi-roman/awesome-claude-code

TaskCreate pattern guidelines for progress tracking in coordinator agents

symfony-knowledge

59
from dykyi-roman/awesome-claude-code

Symfony framework knowledge base. Provides architecture, DDD integration, persistence, DI, security, messenger, workflow, events, infrastructure components, testing, and antipatterns for Symfony PHP projects.

stability-patterns-knowledge

59
from dykyi-roman/awesome-claude-code

Stability Patterns knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Circuit Breaker, Retry, Rate Limiter, Bulkhead, and resilience audits.

solid-knowledge

59
from dykyi-roman/awesome-claude-code

SOLID principles knowledge base for PHP 8.4 projects. Provides quick reference for SRP, OCP, LSP, ISP, DIP with detection patterns, PHP examples, and antipattern identification. Use for architecture audits and code quality reviews.

scalability-knowledge

59
from dykyi-roman/awesome-claude-code

Scalability knowledge base. Provides vertical vs horizontal scaling, stateless design, session management, connection pooling, capacity planning, and PHP-FPM tuning for scalability audits.

saga-pattern-knowledge

59
from dykyi-roman/awesome-claude-code

Saga Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for saga orchestration, choreography, and distributed transaction audits.

replication-sharding-knowledge

59
from dykyi-roman/awesome-claude-code

Replication and Sharding knowledge base. Provides read/write splitting at application level, connection wrapper patterns, replica lag handling, and query routing for database scaling audits.

psr-coding-style-knowledge

59
from dykyi-roman/awesome-claude-code

PSR-1 and PSR-12 coding standards knowledge base for PHP 8.4 projects. Provides quick reference for basic coding standard and extended coding style with detection patterns, examples, and antipattern identification. Use for code style audits and compliance reviews.

psr-autoloading-knowledge

59
from dykyi-roman/awesome-claude-code

PSR-4 autoloading standard knowledge base for PHP 8.4 projects. Provides quick reference for namespace-to-path mapping, composer.json configuration, directory structure, and common mistakes. Use for autoloading audits and project structure reviews.

outbox-pattern-knowledge

59
from dykyi-roman/awesome-claude-code

Outbox Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for transactional outbox, polling publisher, and reliable messaging audits.