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

Global Laravel Remote Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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

  • Low Coupling: The package requires minimal changes to existing Laravel codebases—only a configuration file (config/remote.php) and a facade import. Compatible with Laravel 8+ (PHP 7.4+).
  • Dependency Risk: Relies on 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.
  • Artisan Command Scope: Limited to Artisan commands; does not support direct CLI tool execution (e.g., composer, npm). Requires wrapping such tools in custom Artisan commands.

Technical Risk

  • Authentication Overhead: Requires SSH key setup or password-based auth, which may introduce security risks (e.g., credential leakage in logs/config). Mitigation: Use environment variables for sensitive data and restrict SSH keys to specific commands.
  • Network Dependency: Remote execution adds latency and potential timeout failures if the server is unreachable. No built-in retry logic—requires custom handling (e.g., Laravel’s retry helper).
  • State Management: Artisan commands executed remotely may not persist local state (e.g., cached config, service containers). Test thoroughly for stateful commands (e.g., migrate, queue:work).

Key Questions

  1. Use Case Clarity: Will this replace SSH entirely, or supplement it for specific tasks (e.g., deployments, cron jobs)?
  2. Environment Parity: Are all target servers guaranteed to have identical PHP/Laravel versions? Inconsistencies could break commands.
  3. Auditability: How will remote command execution be logged/audited? The package lacks built-in logging—custom middleware may be needed.
  4. Fallback Strategy: What’s the plan if remote execution fails (e.g., local fallback, manual intervention)?
  5. Performance Impact: For high-frequency commands (e.g., real-time analytics), remote execution may introduce unacceptable latency.

Integration Approach

Stack Fit

  • Laravel-Centric: Optimized for Laravel monoliths or microservices using Artisan. Poor fit for non-Laravel PHP apps or frameworks lacking Artisan.
  • Cloud/Serverless: Works well with AWS ECS, Kubernetes, or serverless Laravel (e.g., Bref) where direct SSH is unavailable.
  • Hybrid Deployments: Useful for blue-green deployments or feature flags where remote rollbacks/commands are needed.

Migration Path

  1. Phase 1: Pilot Commands
    • Start with low-risk commands (e.g., cache:clear, queue:restart) to validate integration.
    • Example:
      use Spatie\Remote\Remote;
      Remote::run('php artisan cache:clear', [
          'host' => 'production-server',
          'username' => env('REMOTE_USER'),
      ]);
      
  2. Phase 2: Configuration
    • Centralize remote hosts in config/remote.php:
      'hosts' => [
          'production' => [
              'host' => env('PROD_SERVER'),
              'username' => env('PROD_USER'),
              'key' => env('SSH_KEY_PATH'),
          ],
      ];
      
    • Use Laravel’s config() helper to avoid hardcoding.
  3. Phase 3: Wrap Critical Commands
    • Create custom Artisan commands (e.g., php artisan deploy:rollback) that internally use Remote::run().
    • Example:
      // app/Console/Commands/DeployRollback.php
      public function handle() {
          Remote::run('php artisan migrate:rollback', ['host' => 'production']);
      }
      

Compatibility

  • Laravel Version: Tested on Laravel 8+; may need adjustments for older versions (e.g., Facade syntax).
  • PHP Extensions: Requires ssh2 or phpseclib for SSH. Docker/Kubernetes environments must include these.
  • Firewall/Network: Ensure outbound SSH (port 22) is allowed between local dev and remote servers.

Sequencing

  1. Pre-Integration:
    • Audit existing Artisan commands for remote viability (avoid stateful or interactive commands).
    • Set up SSH keys with restricted permissions (e.g., command="php artisan queue:work" in authorized_keys).
  2. During Integration:
    • Implement a feature flag to toggle remote execution (e.g., config('remote.enabled')).
    • Add circuit breakers for remote failures (e.g., Laravel Horizon for queue monitoring).
  3. Post-Integration:
    • Deprecate direct SSH access for commands handled by the package.
    • Document remote command usage in the team’s runbook.

Operational Impact

Maintenance

  • Configuration Drift: Remote hosts/configurations may diverge over time. Use Infrastructure as Code (IaC) (e.g., Terraform) to manage SSH keys and server setups.
  • Dependency Updates: Monitor 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.
  • Deprecation Risk: If the package is abandoned (low stars/dependents), fork or replace with alternatives like Laravel Forge or Deployer.

Support

  • Debugging Complexity: Remote command failures are harder to debug than local ones. Implement:
    • Verbose Logging: Extend the package to log command output to Laravel’s log channel.
    • Error Tracking: Integrate with Sentry/Error Tracking to capture remote execution failures.
  • Access Control: Restrict SSH keys to specific team members to prevent unauthorized remote commands.

Scaling

  • Performance Bottlenecks: Remote execution adds ~100ms–1s latency per command. For high-throughput systems (e.g., cron jobs), batch commands or use local execution where possible.
  • Concurrency Limits: SSH connections may be rate-limited. Use connection pooling (e.g., spatie/ssh’s ConnectionManager) or queue remote commands (e.g., via Laravel Queues).
  • Multi-Region Deployments: Latency increases for cross-region commands. Consider regional command routing (e.g., execute in the same AZ as the target server).

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

  • Onboarding: Requires SSH knowledge and Laravel Artisan familiarity. Provide a cheat sheet for common remote commands (e.g., Remote::run('php artisan optimize')).
  • Training: Conduct a workshop on:
    • Secure SSH key management.
    • Debugging remote command failures.
    • Performance tuning (e.g., avoiding long-running remote commands).
  • Documentation: Extend the README with:
    • Example workflows (e.g., "How to use this for zero-downtime deployments").
    • Troubleshooting guide (e.g., "My command hangs—what’s wrong?").
  • Tooling: Integrate with Laravel Nova or Telescope to visualize remote command usage.
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