mtdowling/burgomaster
Laravel package for controlling and monitoring long-running background tasks and daemons. Provides a simple master/worker process manager, status reporting, and a structured way to start, stop, and supervise job runners from your app or CLI.
Installation Add Burgomaster via Composer:
composer require mtdowling/burgomaster
No Laravel-specific configuration is needed—Burgomaster works out-of-the-box with Composer projects.
First Use Case: Packaging a Laravel Artisan Command
Create a PHAR of a standalone Artisan command (e.g., app/Console/Commands/MyCommand.php):
burgomaster create my-command.phar --main=vendor/bin/my-command
This generates a self-contained PHAR that consumers can run with:
php my-command.phar
Where to Look First
burgomaster --help for command-line options.Illuminate\Console\Command and package the command’s entry point.Packaging Artisan Commands Create a PHAR for a custom Artisan command:
burgomaster create my-command.phar \
--main=vendor/bin/my-command \
--exclude=vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php
--main to point to the command’s entry point (e.g., vendor/bin/my-command).Bundling Laravel Assets Include frontend assets (e.g., JS/CSS) compiled by Laravel Mix:
burgomaster create my-package.phar \
--include=public/ \
--include=resources/js/dist/
npm run prod → php artisan build → package the output.PHARs for Laravel Plugins Package a plugin as a PHAR for easy distribution:
burgomaster create my-plugin.phar \
--main=vendor/autoload.php \
--stub=phar://stub.txt \
--exclude=tests/
stub.txt):
<?php
Phar::mapPhar('my-plugin.phar');
require 'phar://my-plugin.phar/vendor/autoload.php';
require 'phar://my-plugin.phar/src/MyPluginServiceProvider.php';
CI/CD Integration Automate PHAR generation in GitHub Actions:
- name: Build PHAR
run: |
composer install --optimize-autoloader
burgomaster create my-app.phar \
--main=public/index.php \
--exclude=bootstrap/cache/* \
--sign --signer=key.pem
composer install --optimize-autoloader for smaller PHARs.Debugging PHARs Test locally with:
burgomaster create my-debug.phar --verbose
--verbose to inspect included/excluded files.Composer Scripts
Add PHAR generation to composer.json:
"scripts": {
"post-autoload-dump": "burgomaster create my-package.phar --main=vendor/bin/cli",
"package": "burgomaster create my-package.zip"
}
Run with:
composer package
Laravel Service Providers For PHARs that include Laravel logic, manually register providers in the stub:
// stub.txt
<?php
Phar::mapPhar('my-package.phar');
$loader = require 'phar://my-package.phar/vendor/autoload.php';
$loader->addPsr4('MyPackage\\', 'phar://my-package.phar/src');
new MyPackage\ServiceProvider($app);
Dependency Management
--include to add non-Composer files (e.g., config/).--exclude to trim bloat (e.g., node_modules, tests).PHAR vs. ZIP
PHAR Security
phar.readonly=0 in php.ini (disabled by default for security).--sign and validate on load:
burgomaster create my-package.phar --sign --signer=key.pem
Dynamic Code
class_alias, eval).composer require --dev phpstan/phpstan
vendor/bin/phpstan analyse --level=7
Laravel-Specific Quirks
config/ or routes/ dynamically.// stub.txt
<?php
putenv('APP_ENV=production');
Dependency Bloat
vendor/ dependencies, increasing size.--exclude to trim unused vendors:
burgomaster create my-package.phar --exclude=vendor/doctrine/*
Debugging
phar:// paths, making debugging harder.--verbose to inspect contents and log PHAR paths:
burgomaster create my-package.phar --verbose
Inspect PHAR Contents List files in a PHAR:
phar -l my-package.phar
Test PHAR Locally
Run the PHAR with php -d phar.readonly=0:
php -d phar.readonly=0 my-package.phar
Validate Signatures Check PHAR signatures:
burgomaster validate my-package.phar --public-key=key.pub
Custom Stubs Override the default PHAR stub by passing a file:
burgomaster create my-package.phar --stub=custom-stub.txt
Pre/Post-Package Scripts Hook into Composer scripts to extend Burgomaster:
"scripts": {
"post-package": "php artisan optimize"
}
Streaming to S3 Pipe PHARs directly to cloud storage:
$burgomaster->package('src/', null, ['stream' => true])
->pipeTo(fopen('s3://my-bucket/my-package.phar', 'w'));
Artisan Commands in PHARs
// stub.txt
<?php
Phar::mapPhar('my-command.phar');
require 'phar://my-command.phar/vendor/autoload.php';
$command = new \MyNamespace\MyCommand();
$command->handle();
PHARs and OPCache
; php.ini
opcache.enable=1
opcache.enable_file_override=1
Environment-Specific Packaging
--env to package different configs for dev/prod:
burgomaster create my-package-prod.phar --include=config/production.php
How can I help you explore Laravel packages today?