Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Remote

Laravel Remote Laravel Package

spatie/laravel-remote

Run Laravel Artisan commands on remote servers over SSH. Configure one or more hosts (default host, user, port, path, optional private key) and execute tasks like cache clears via php artisan remote ..., with optional confirmation prompts.

View on GitHub
Deep Wiki
Context7

Execute Artisan commands on a remote server

Frequently asked questions about Laravel Remote
How do I install and set up spatie/laravel-remote in my Laravel project?
Run `composer require spatie/laravel-remote` to install the package, then publish the config with `php artisan vendor:publish --tag="remote-config"`. Configure your remote hosts in the generated `config/remote.php` file, using environment variables for sensitive details like SSH keys.
Can I execute any Artisan command remotely, or are there limitations?
You can execute any Artisan command remotely, but the package relies on SSH access to the remote server. Commands must be valid in the remote environment, and output is streamed back to your local terminal. Complex commands with interactive prompts may not work as expected.
How do I specify which remote host to use when running a command?
Use the `--host` option with your Artisan command, e.g., `php artisan remote --host=staging cache:clear`. If no host is specified, the package will use the `default_host` defined in the config file.
Is there a way to require confirmation before running remote commands for safety?
Yes, set `'needs_confirmation' => true` in the config file or use the `REMOTE_NEEDS_CONFIRMATION` environment variable. This will prompt you to confirm before executing any remote command, reducing accidental runs.
What Laravel and PHP versions does spatie/laravel-remote support?
The package is officially tested with Laravel 10+ and requires PHP 8.1 or higher. Always check the package’s `composer.json` for the latest supported versions, as Spatie occasionally updates compatibility.
How do I handle SSH authentication for remote servers? Can I use private keys?
You can authenticate using SSH keys by specifying the `privateKeyPath` in your host configuration. Store the path to your private key in the config or use environment variables. Avoid hardcoding credentials; use Laravel’s `.env` file for sensitive data.
What happens if a remote command fails? Are there retries or error handling?
The package does not include built-in retry logic or rollback mechanisms. Failed commands will exit with an error, and you’ll see the remote output in your terminal. Implement custom error handling or retries in your application logic if needed.
Can I use spatie/laravel-remote in CI/CD pipelines or automated deployments?
Yes, it’s ideal for CI/CD pipelines. Configure your remote hosts in your pipeline’s environment variables and use commands like `php artisan remote deploy` in your deployment scripts. Disable confirmation prompts (`needs_confirmation`) for automated workflows.
How do I test remote commands locally without hitting actual servers?
Mock SSH calls using PHP’s `Process` class or tools like `phpseclib` for unit testing. Alternatively, set up a local Docker container with SSH enabled to simulate remote environments. Avoid testing against production servers.
Are there alternatives to spatie/laravel-remote for running remote Artisan commands?
Alternatives include using SSH directly via PHP’s `exec()` or libraries like `phpseclib`, or tools like Deployer or Ansible for more complex workflows. However, `spatie/laravel-remote` is tailored for Laravel and offers a seamless, config-driven approach.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport