- How do I install acassan/remoteserver in a Laravel project?
- Run `composer require acassan/remoteserver` in your project directory. The package requires PHP 8.1+ and Laravel 9+. Register the service provider in `config/app.php` or use Laravel’s autoloading if no provider is needed. Configure SSH credentials in your `.env` file or Laravel config.
- Can I use this package to run SSH commands in Laravel background jobs?
- Yes, but you’ll need to wrap the package in a custom job class with retry logic since the package itself blocks execution. Use Laravel’s `ShouldQueue` interface and implement retries for transient failures. Avoid direct SSH calls in queues without error handling.
- What Laravel versions does acassan/remoteserver support?
- The package is compatible with Laravel 9+ and requires PHP 8.1+. It leverages Laravel’s service container for dependency injection, making it easy to integrate with newer Laravel features like Tasks (Laravel 11+) or Jobs with minimal adjustments.
- How do I securely manage SSH credentials for remote servers?
- Never hardcode credentials. Use Laravel’s `env()` function or a dedicated secrets manager like HashiCorp Vault to store SSH keys or passwords. The package itself doesn’t enforce security practices, so validate inputs and restrict permissions on remote servers.
- Does this package support SFTP or SCP file transfers?
- No, the package only supports SSH command execution and basic file upload/download via streams. For SFTP/SCP, consider alternatives like `league/flysystem-aws` or `phpseclib` directly, though they require more boilerplate code.
- How can I mock remote server interactions for testing?
- Use PHPUnit mocks for the `RemoteServerInterface` or set up a Dockerized test environment with a mock SSH server. Libraries like `phpseclib` provide mocking utilities, or you can stub the package’s `execute()` method in unit tests to avoid real network calls.
- Will this package work in high-throughput environments like cron jobs?
- The package blocks execution during SSH calls, so it’s not ideal for high-frequency operations. Implement connection pooling or circuit breakers (e.g., `spatie/flysystem-circuit-breaker`) to handle latency. For async workflows, wrap calls in Laravel queues with retry logic.
- Are there alternatives to acassan/remoteserver for Laravel?
- For SSH automation, consider `phpseclib` directly for full control or `league/glide` for file transfers. Laravel’s `Artisan` commands with SSH can also work, but they’re less reusable. This package excels in encapsulating remote logic in a Laravel-friendly way.
- How do I handle errors or failed SSH commands in production?
- The package throws exceptions on failures. Log errors using Laravel’s logging system or integrate with monitoring tools like Sentry. Implement custom retry logic in your application code for transient issues, as the package lacks built-in retries.
- Can I use this package to manage multiple remote servers with different credentials?
- Yes, configure multiple server connections in Laravel’s config or environment files. The package supports passing different credentials per connection, but ensure proper isolation to avoid credential leaks. Use Laravel’s `config()` helper to dynamically switch between servers.