reedware/sail-lite
Sail Lite is a lightweight CLI for PHP package development using a baseline Docker environment. It ships a docker-compose.yml and a sail script that wrap common Docker Compose tasks (up, down, build, exec), inspired by Laravel Sail but framework-agnostic.
Installation:
composer require reedware/sail-lite --dev
./vendor/bin/sail install
This publishes the docker-compose.yml and sail script to your project root.
Start the Container:
sail up -d
Runs the PHP development container in detached mode.
Access the Container:
sail shell
Drops you into a bash shell inside the container with your project mounted at /var/www/html.
Run PHP Commands:
sail php artisan test # Example for testing (if applicable)
sail php vendor/bin/phpunit
sail shell to run tests, linting, or other CLI tools inside the container.sail php to execute PHP scripts or run Composer commands:
sail php -r "require_once 'vendor/autoload.php'; echo \MyPackage\MyClass::version();"
Start/Stop:
sail up -d # Start in background
sail down # Stop containers
Rebuilding:
sail down && sail build --no-cache && sail up -d
Use this when updating PHP versions or adding new dependencies.
Shell Access:
sail shell # User-level shell (default)
sail root-shell # Root-level shell (for admin tasks)
docker-compose.yml:
args:
PHP: '8.2' # Hardcoded override
Or set in .env:
PHP_VERSION=8.1
sail down && sail build --no-cache && sail up -d
sail publish
This creates a /docker directory with customizable Dockerfiles and configs.docker-compose.yml:
Example: Add PHP extensions or tools:
services:
dev:
build:
context: ./docker
args:
PHP_EXTENSIONS: "pdo_mysql, gd"
sail php -v # Runs `php -v` inside the container
sail composer install
sail npm install # If Node.js is added via customization
php proxy (added in v1.3.0) for seamless debugging:
// .vscode/settings.json
{
"php.validate.executablePath": "/var/www/html/vendor/bin/sail php"
}
.env:
PHP_VERSION=8.2
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker-compose up -d
- run: docker-compose exec dev sail php vendor/bin/phpunit
Composer Scripts:
Add Sail commands to composer.json for convenience:
"scripts": {
"dev": "sail shell",
"test": "sail php vendor/bin/phpunit",
"lint": "sail php vendor/bin/php-cs-fixer fix"
}
Now run with:
composer dev
Environment Variables:
Use .env to manage container settings (e.g., PHP version, user permissions):
PHP_VERSION=8.1
WWWUSER=1000
Multi-Package Development:
Rename the service in docker-compose.yml to avoid conflicts:
services:
my-package-dev: # Unique name
image: sail-lite/basic
...
PHP Version Mismatches:
PHP_VERSION in .env or docker-compose.yml.sail build --no-cache after PHP version changes.Permission Errors:
chmod: Permission denied).WWWUSER and WWWGROUP in docker-compose.yml match your host’s UID/GID. Use:
sail root-shell
id www-data # Check UID/GID
Missing Extensions:
pdo_mysql) are missing.sail publish and add extensions:
RUN docker-php-ext-install pdo_mysql gd
Shell Alias Conflicts:
sail alias may conflict with Laravel Sail or other tools../vendor/bin/sail) or rename the alias (e.g., alias sl='./vendor/bin/sail').Assertions Disabled:
docker-compose.yml:
args:
PHP_INI_VALUES: "assert.active=0"
Volume Mounts:
docker-compose.yml volumes may not reflect immediately.sail down && sail up -d
Check Container Logs:
sail logs
Useful for diagnosing build or startup issues.
Inspect Running Containers:
docker ps
docker inspect <container_id>
Test PHP Configuration:
sail php -i | grep "assert"
sail php -m # List loaded extensions
.env File Location:
.env in the project root. If missing, defaults are used.Default PHP Version:
8.5 unless overridden. Check docker-compose.yml for the PHP arg.Custom Dockerfiles:
/docker override defaults but require rebuilding:
sail build --no-cache
VSCode Debugging:
php proxy is configured in .vscode/settings.json (added in v1.3.0). Without it, debugging may fail.Add Node.js:
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
Add Databases:
docker-compose.yml to include services like MySQL or PostgreSQL, then link them to the PHP container.Custom PHP.ini Settings:
PHP_INI_VALUES to docker-compose.yml:
args:
PHP_INI_VALUES: "memory_limit=2G, display_errors=1"
Multi-Stage Builds:
Dockerfile in /docker with multi-stage builds.Health Checks:
docker-compose.yml for CI/CD readiness:
healthcheck:
test: ["CMD", "sail", "php", "-r", "exit((file_exists('vendor/autoload.php')) ? 0 : 1);"]
interval: 30s
timeout: 10s
retries: 3
How can I help you explore Laravel packages today?