- How do I install spatie/global-laravel-remote globally for Laravel projects?
- Run `composer global require spatie/global-laravel-remote` to install it globally. Ensure your Composer global bin directory is in your system PATH so you can execute `global-laravel-remote` from any terminal.
- Can I use this package to run Artisan commands on Laravel 7 or older?
- No, this package is officially supported for Laravel 8+ (PHP 7.4+). Older versions may require adjustments to Facade syntax or dependency versions, but it’s not guaranteed to work without modifications.
- How do I configure remote server credentials securely?
- Store sensitive credentials like SSH keys or passwords in environment variables (e.g., `REMOTE_USER`, `SSH_KEY_PATH`) and reference them in your `config/remote.php` file. Avoid hardcoding credentials in configuration files.
- What happens if the remote server is unreachable or the command fails?
- The package doesn’t include built-in retry logic, so failures will throw exceptions. Handle errors with try-catch blocks or wrap commands in Laravel’s retry helper for resilience. Log failures for debugging.
- Does this package support running non-Artisan commands like `composer` or `npm`?
- No, it’s designed exclusively for Artisan commands. To run other CLI tools, wrap them in custom Artisan commands or use alternative tools like SSH directly for broader functionality.
- How do I log or audit remote command executions for security compliance?
- The package doesn’t include built-in logging. Use Laravel’s logging system or middleware to log commands before execution. For audit trails, consider integrating with tools like AWS CloudTrail or custom database logs.
- Will this work in Docker or Kubernetes environments where SSH isn’t available?
- No, it requires SSH access to the remote server. For containerized environments, use Kubernetes Jobs, CronJobs, or direct container execution instead of remote SSH-based solutions.
- Can I use this for high-frequency tasks like real-time queue processing?
- It’s not ideal for high-frequency tasks due to added latency from remote execution. For real-time processing, run queue workers directly on the target server or use serverless functions with local queue listeners.
- Are there alternatives to this package for remote Laravel command execution?
- Yes, alternatives include Laravel Forge’s CLI tools, Deployer (for PHP projects), or custom SSH scripts. However, this package is lightweight and Laravel-specific, focusing solely on Artisan commands without extra deployment complexity.
- How do I test remote command execution in a CI/CD pipeline?
- Mock the `Remote` facade in tests using Laravel’s mocking tools (e.g., `Mockery`). Test edge cases like failed connections or invalid commands by simulating exceptions in your test environment.