dimer47/zero

Lightweight Docker wrapper for Laravel Zero CLI applications, inspired by Laravel Sail

Maintainers

Package info

github.com/dimer47/zero

Language:Shell

pkg:composer/dimer47/zero

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-01-22 10:41 UTC

This package is auto-updated.

Last update: 2026-03-22 11:23:04 UTC


README

Laravel Zero

Latest Stable Version License

A minimal Docker wrapper for Laravel Zero, inspired by Laravel Sail but designed specifically for CLI applications.

โœจ Features

  • ๐Ÿš€ Ephemeral Containers - Each command runs in a fresh container, no daemon needed
  • ๐ŸŽฏ Auto-detection - Automatically detects your application binary from composer.json
  • ๐Ÿ˜ Multi PHP Version - Support for PHP 8.2, 8.3, and 8.4
  • ๐Ÿชถ Alpine-based - Ultra-lightweight images (~50MB vs ~1GB)
  • ๐Ÿ“ฆ Ready to use - One command installation

๐Ÿ“‹ Requirements

  • Docker Desktop (macOS/Windows) or Docker Engine (Linux)
  • Docker Compose v2+
  • A Laravel Zero project

๐Ÿš€ Installation

composer require dimer47/zero --dev

Publish the Docker configuration:

php application zero:install

This will:

  • Create docker-compose.yml - Docker Compose configuration
  • Set PHP_VERSION in your .env file (created if needed)

You can specify a different PHP version:

php application zero:install --php=8.4

Build the Docker image:

./vendor/bin/zero build

๐ŸŽฏ Shell Alias (Recommended)

For a better developer experience, add this alias to your shell configuration (~/.zshrc or ~/.bashrc):

alias zero='$([ -f zero ] && echo ./zero || echo ./vendor/bin/zero)'

Then reload your shell:

source ~/.zshrc  # or source ~/.bashrc

Now you can use zero directly instead of ./vendor/bin/zero:

zero list
zero build
zero pest

๐Ÿ“– Usage

๐ŸŽฏ Application Commands

# List all available application commands
./vendor/bin/zero list

# Run any application command (binary auto-detected from composer.json)
./vendor/bin/zero server:list
./vendor/bin/zero make:command MyCommand

โšก Laravel Zero Commands

# Run tests
./vendor/bin/zero test

# Build PHAR executable (output in builds/ directory)
./vendor/bin/zero app:build my-app

# Install optional components
./vendor/bin/zero app:install

# Rename your application
./vendor/bin/zero app:rename my-new-name

# Create a new command
./vendor/bin/zero make:command

# Create a new test
./vendor/bin/zero make:test

๐Ÿ˜ PHP & Composer

# Run PHP commands
./vendor/bin/zero php -v
./vendor/bin/zero php script.php

# Run Composer commands
./vendor/bin/zero composer install
./vendor/bin/zero composer require vendor/package
./vendor/bin/zero composer update

๐Ÿงช Testing & Code Style

# Run Pest tests
./vendor/bin/zero pest
./vendor/bin/zero pest --filter=MyTest
./vendor/bin/zero pest --coverage

# Run Pint code style fixer
./vendor/bin/zero pint
./vendor/bin/zero pint --test      # Check without fixing
./vendor/bin/zero pint --dirty     # Only changed files
./vendor/bin/zero pint app/        # Specific directory

๐Ÿš Container Access

# Start an interactive shell
./vendor/bin/zero shell
./vendor/bin/zero bash

๐Ÿณ Docker Management

# Build the Docker image
./vendor/bin/zero build

# Rebuild without cache
./vendor/bin/zero build --no-cache

โš™๏ธ Configuration

Environment Variables

Create a .env file at your project root:

# PHP version (8.2, 8.3, or 8.4)
PHP_VERSION=8.3

# UID/GID for file permissions (match your local user)
ZEROUSER=1000
ZEROGROUP=1000

๐Ÿท๏ธ Multiple Projects

By default, all Laravel Zero projects using the same PHP version share the same Docker image (zero-8.3/app). This is efficient for most use cases since the image only contains PHP and system extensions, while your code and dependencies are mounted via volumes.

However, if you need to customize the Docker image for a specific project (e.g., adding extra PHP extensions), you can isolate it by setting COMPOSE_PROJECT_NAME in your .env:

COMPOSE_PROJECT_NAME=my-project

This will create a separate image named my-project-zero-8.3/app, preventing conflicts with other projects.

Docker Compose

The default docker-compose.yml:

services:
    laravel.zero:
        build:
            context: ./vendor/dimer47/zero/runtimes/${PHP_VERSION:-8.3}
            dockerfile: Dockerfile
            args:
                ZEROGROUP: '${ZEROGROUP:-1000}'
                ZEROUSER: '${ZEROUSER:-1000}'
        image: zero-${PHP_VERSION:-8.3}/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        environment:
            ZEROUSER: '${ZEROUSER:-1000}'
            ZEROGROUP: '${ZEROGROUP:-1000}'
        volumes:
            - '.:/var/www/html'
        networks:
            - zero
networks:
    zero:
        driver: bridge

๐Ÿ”ง How It Works

Unlike Laravel Sail which runs a persistent container, Zero uses ephemeral containers optimized for CLI workflows:

  1. ๐Ÿ“ฆ Each command spawns a new container
  2. โšก The command executes
  3. ๐Ÿ—‘๏ธ The container is automatically removed

This approach is more efficient for CLI applications where you run occasional commands rather than maintaining a web server.

๐ŸŽฏ Binary Auto-Detection

Zero automatically reads your composer.json to find your application binary:

{
    "bin": ["my-app"]
}

This means ./vendor/bin/zero list will execute php my-app list inside the container.

๐Ÿ”Œ PHP Extensions

The Docker images include essential extensions for Laravel Zero:

  • PDO / PDO MySQL
  • Zip
  • MBString
  • Intl
  • PCntl
  • BCMath

The images also include useful system tools: git, curl, jq (JSON parsing), composer.

Adding Extensions

To add more PHP extensions, create your own Dockerfile extending the base image, or copy the runtime to your project and customize it.

๐Ÿ“š Command Reference

Command Description
zero Display help
zero list List all application commands
zero <command> Run application command
zero build Build Docker image
zero php ... Run PHP command
zero composer ... Run Composer command
zero pest ... Run Pest tests
zero pint ... Run Pint code fixer
zero shell Start interactive shell
zero test Run application tests
zero app:build Build PHAR executable
zero app:install Install optional components
zero app:rename Rename application
zero make:command Create new command
zero make:test Create new test

โš–๏ธ Comparison with Laravel Sail

Feature Laravel Sail Zero
Target Web applications CLI applications
Container model Persistent (up/stop) Ephemeral (run/exit)
Base image Ubuntu (~1GB) Alpine (~50MB)
Services MySQL, Redis, etc. PHP only
Binary detection artisan hardcoded Auto from composer.json

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

This package is open-source software licensed under the MIT license.

๐Ÿ™ Credits

๐Ÿ†˜ Support