spatie/global-laravel-remote
Run Laravel artisan commands on a remote server from your terminal. Install globally via Composer and execute with global-laravel-remote "{cmd}" to trigger remote artisan tasks without SSHing into the machine each time.
Architecture Fit
The spatie/global-laravel-remote package enables remote execution of Artisan commands on Laravel servers, bridging local development and production environments. It aligns well with microservices, multi-tier deployments, or CI/CD pipelines where direct server access is restricted (e.g., shared hosting, cloud VMs, or security-hardened environments). The package abstracts SSH/SSH-key management by encapsulating command execution behind a Laravel facade (Remote::run()), making it ideal for serverless or containerized Laravel apps where manual SSH is impractical.
Integration Feasibility
config/remote.php) and a facade import. Compatible with Laravel 8+ (PHP 7.4+).spatie/ssh (for SSH operations) and symfony/process (for command execution). Both are battle-tested, but version conflicts could arise if the project uses older Laravel/Symfony versions.composer, npm). Requires wrapping such tools in custom Artisan commands.Technical Risk
retry helper).migrate, queue:work).Key Questions
Stack Fit
Migration Path
cache:clear, queue:restart) to validate integration.use Spatie\Remote\Remote;
Remote::run('php artisan cache:clear', [
'host' => 'production-server',
'username' => env('REMOTE_USER'),
]);
config/remote.php:
'hosts' => [
'production' => [
'host' => env('PROD_SERVER'),
'username' => env('PROD_USER'),
'key' => env('SSH_KEY_PATH'),
],
];
config() helper to avoid hardcoding.php artisan deploy:rollback) that internally use Remote::run().// app/Console/Commands/DeployRollback.php
public function handle() {
Remote::run('php artisan migrate:rollback', ['host' => 'production']);
}
Compatibility
ssh2 or phpseclib for SSH. Docker/Kubernetes environments must include these.Sequencing
command="php artisan queue:work" in authorized_keys).config('remote.enabled')).Maintenance
spatie/ssh and symfony/process for breaking changes. Example: If spatie/ssh drops PHP 7.4 support, the package may need a Laravel version bump.Support
Scaling
spatie/ssh’s ConnectionManager) or queue remote commands (e.g., via Laravel Queues).Failure Modes
| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| SSH Key Compromise | Unauthorized command execution | Rotate keys via IaC; use short-lived keys. |
| Network Outage | Command timeouts | Implement retries with exponential backoff. |
| PHP Version Mismatch | Command failures | Use Docker or containerized Laravel. |
| Resource Exhaustion (CPU/RAM) | Slow/failed commands | Monitor server resources; optimize commands. |
| Artisan Command Bugs | Remote state corruption | Test commands in staging first. |
Ramp-Up
Remote::run('php artisan optimize')).How can I help you explore Laravel packages today?