sweetchuck/composer-suite-handler
Installation Add the package to your Laravel project via Composer:
composer require sweetchuck/composer-suite-handler
Register the service provider in config/app.php under providers:
Sweetchuck\ComposerSuiteHandler\ComposerSuiteHandlerServiceProvider::class,
First Use Case Use the package to handle Composer Suite operations programmatically. Example:
use Sweetchuck\ComposerSuiteHandler\Facades\ComposerSuiteHandler;
// Initialize Composer Suite
$composerSuite = ComposerSuiteHandler::init();
// Run a basic command (e.g., install dependencies)
$result = $composerSuite->run('install');
Where to Look First
app/ComposerSuiteHandler (if using facades).config/composer-suite.php (if available).Programmatic Composer Operations Use the handler to execute Composer Suite commands without CLI interaction:
// Update packages
$composerSuite->run('update', ['--with-dependencies' => true]);
// Require a package
$composerSuite->run('require', ['monolog/monolog' => '2.*']);
Event-Driven Integration Hook into Composer Suite lifecycle events (if supported) via Laravel events:
// Example: Listen for post-install events
event(new ComposerSuiteInstalled($result));
Configuration Management Override default Composer Suite behavior via config:
// config/composer-suite.php (if created)
return [
'timeout' => 300,
'verbose' => env('COMPOSER_VERBOSE', false),
];
Artisan Command Integration Extend Laravel’s Artisan to wrap Composer Suite commands:
namespace App\Console\Commands;
use Sweetchuck\ComposerSuiteHandler\Facades\ComposerSuiteHandler;
use Illuminate\Console\Command;
class UpdateDependencies extends Command
{
protected $signature = 'composer:update';
public function handle()
{
$result = ComposerSuiteHandler::run('update');
$this->info($result['output']);
}
}
# Example GitHub Actions step
- name: Update Composer Dependencies
run: php artisan composer:update
No Official Laravel Integration
Error Handling
$result:
if ($result['success']) {
// Proceed
} else {
throw new \RuntimeException($result['error']);
}
Configuration Overrides
config/ by default. Explicitly pass config:
$composerSuite = ComposerSuiteHandler::init(['timeout' => 600]);
Dependency Conflicts
composer require programmatically may conflict with Laravel’s autoloader. Use dump-autoload post-operation:
$composerSuite->run('dump-autoload');
$composerSuite = ComposerSuiteHandler::init(['verbose' => true]);
\Log::debug('Running Composer Suite command', ['command' => 'update', 'args' => [...]]);
Custom Commands Extend the handler to support domain-specific commands:
// Example: Add a custom 'audit' command
$composerSuite->extend('audit', function () {
return shell_exec('composer audit');
});
Event Listeners Dispatch Laravel events post-operation:
event(new ComposerOperationCompleted(
$result,
$command
));
Testing Mock the handler in tests:
$this->mock(Sweetchuck\ComposerSuiteHandler\Facades\ComposerSuiteHandler::class)
->shouldReceive('run')
->once()
->andReturn(['success' => true]);
How can I help you explore Laravel packages today?