coringawc/filament-plugin-workbench
Docker-based dev workbench for FilamentPHP plugin authors. Includes a generic PHP 8.4/Node 22/Composer 2 image, auto-install entrypoint, docker-compose and testbench templates, and a workbench/sail CLI to run artisan, tests, and tooling without local PHP/Node.
Add as a Git Submodule:
git submodule add https://github.com/CoringaWc/filament-plugin-workbench.git packages/workbench
Initialize Workbench:
./vendor/bin/workbench up
docker-compose.yml.stub and testbench.yaml.stub to your plugin root.build.context dynamically to point to the Dockerfile in the submodule.Start Development:
./vendor/bin/sail artisan serve
http://localhost:8001 (default port in stub)../vendor/bin/sail test
./vendor/bin/sail lint
./vendor/bin/sail shell
Plugin Development Loop:
# Start environment (detached)
./vendor/bin/workbench up -d
# Run tests in watch mode
./vendor/bin/sail test --watch
# Serve the plugin
./vendor/bin/sail artisan serve
Fresh Environment:
./vendor/bin/workbench fresh # Migrate + seed
Debugging:
./vendor/bin/workbench logs # Tail container logs
./vendor/bin/sail shell # Interactive shell
Docker Context Resolution:
The build.context in docker-compose.yml is dynamically replaced with the path to the submodule's Dockerfile (packages/workbench/docker/php). Use _fix_docker_context() to handle this during workbench up.
Provider Auto-Injection:
The testbench.yaml stub includes a placeholder (# - Vendor\YourPlugin\...). Run ./vendor/bin/workbench up to auto-fill providers from composer.json under extra.laravel.providers.
Composer Scripts:
The composer.json stub injects scripts like bootstrap:workbench, serve, and fresh:workbench. These are auto-generated if missing.
Playwright Integration:
If your plugin uses @playwright/test, the Docker image pre-installs Chromium in a named volume (playwright-browsers). No manual setup required—just include the dependency in package.json.
Custom Dockerfile:
Override the Dockerfile by extending the base image in your plugin’s docker-compose.yml:
services:
php:
build:
context: ./packages/workbench/docker/php
dockerfile: Dockerfile.extends # Your custom Dockerfile
Environment Variables:
Use .env files in your plugin root. The stub includes comments for all available variables (e.g., DB_DATABASE, APP_URL).
Volume Mounts:
Mount plugin directories explicitly in docker-compose.yml:
volumes:
- ./:/var/www/html:cached
- ./vendor:/var/www/html/vendor:cached
POSIX Compliance:
bin/workbench is written in POSIX sh (no Bashisms like [[, arrays, or $BASH_SOURCE). Test with:
sh -n ./vendor/bin/workbench
workbench.Docker Context Path:
workbench up fails with build.context errors, manually verify the path in docker-compose.yml:
./vendor/bin/workbench up --force # Overwrites stubs (use cautiously)
Provider Mismatch:
ClassNotFoundException, ensure extra.laravel.providers in composer.json matches your plugin’s namespace. Run:
./vendor/bin/workbench up # Re-injects providers
Playwright Caching:
playwright-browsers volume exists and is owned by the workbench user (handled automatically by the Dockerfile).Host Dependencies:
php, composer, or node directly on the host. All commands must proxy through docker compose exec (e.g., ./vendor/bin/sail artisan).Symlink Resolution:
./vendor/bin/workbench or ./vendor/bin/sail fails, resolve symlinks manually:
readlink -f ./vendor/bin/workbench
Container Logs:
./vendor/bin/workbench logs
php service logs.Shell Access:
./vendor/bin/sail shell
composer dump-autoload).Docker Compose Validation:
docker compose config
docker-compose.yml for syntax errors.Composer Cache:
./vendor/bin/sail composer clear-cache
Custom Dockerfile:
Dockerfile.extends in your plugin root and referencing it in docker-compose.yml:
build:
context: ./packages/workbench/docker/php
dockerfile: Dockerfile.extends
Custom Entrypoint:
entrypoint.sh by copying it to your plugin root and updating the command in docker-compose.yml:
command: ["/var/www/html/entrypoint.sh"]
Additional Services:
docker-compose.yml to include databases, Redis, or other services:
services:
database:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: plugin_db
Custom Workbench Commands:
bin/workbench (POSIX sh) or bin/sail (Bash) following the subcommand reference. Example:
# In bin/workbench
cmd_migrate() {
docker compose exec php php artisan migrate
}
Add to the case block:
migrate) cmd_migrate "$@";;
Testbench Database:
DB_DATABASE to /var/www/html/vendor/orchestra/testbench-core/laravel/database/database.sqlite by default. For HTTP requests, this avoids Testbench’s in-memory :memory: database. Override in .env if needed:
DB_DATABASE=mysql
Provider Auto-Fill:
_ensure_providers() fails silently, check:
extra.laravel.providers exists in composer.json.# - Vendor\YourPlugin\... is present in testbench.yaml.Volume Ownership:
/tmp/.cache/ms-playwright, ensure the Dockerfile pre-creates the directory with the correct ownership (handled automatically in the base image).Layer Caching:
RUN block to avoid cache invalidation for plugins not using Playwright.Composer Install:
entrypoint.sh skips composer install if vendor/autoload.php exists, speeding up container restarts.Node Modules:
npm install is skipped if node_modules/ exists, reducing rebuild time.How can I help you explore Laravel packages today?