Weave 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

Php Ssh Laravel Package

mikemeier/php-ssh

A PHP library for working with SSH connections. Connect to remote servers, execute commands, and manage secure shell sessions through a clean, object-oriented API. Useful for deployment scripts, remote automation, and server administration in any PHP project.

View on GitHub
Deep Wiki
Context7

An experimental object oriented SSH api in PHP

Frequently asked questions about Php Ssh
Does mikemeier/php-ssh work with Laravel?
Yes. The library is framework-agnostic and has no Laravel dependency, so you can install it with Composer and use it inside Laravel Artisan commands, jobs, or deployment scripts. You do not need a service provider or facade; instantiate the SSH client directly in your own service classes. This makes it a good fit for zero-downtime deploy scripts that push files over SFTP and run remote commands.
How do I install mikemeier/php-ssh?
Install it through Composer with composer require mikemeier/php-ssh. Because it wraps the native ssh2 extension rather than reimplementing SSH in PHP, that extension (with libssh2) must be enabled in your PHP runtime. After installation you can autoload the classes and start a connection with password or public-key credentials.
What are the requirements for using this SSH client?
The main requirement is PHP with the ssh2 extension enabled, since the library delegates the actual SSH protocol work to it. You also need Composer for autoloading, plus a reachable SSH server and valid credentials. Check the composer.json in the repository for the supported PHP versions before adding it to an older project.
How do I authenticate with a password or an SSH key?
The library supports both password and public-key authentication through its fluent connection setup. For key-based logins you point the client at a private key file, and you can supply a passphrase when the key is encrypted. Password authentication is convenient for quick scripts, but key-based access is the better choice for automated deployment pipelines.
Can I upload, download, and list files over SFTP?
Yes. SFTP support is built in, so you can upload local files to a remote server, download remote files, and list directory contents without calling low-level ssh2 functions yourself. This is useful for release artifacts, config files, and log retrieval in deployment or automation scripts. Combine it with remote command execution to build a complete deploy or backup workflow.
How do I capture command output and the exit code?
When you run a remote command, the library returns the captured stdout, stderr, and exit code so you can inspect the result instead of guessing whether the command succeeded. Always branch on the exit code rather than parsing stdout text, and log stderr for diagnosis. That pattern keeps deployment scripts from continuing after a failed remote step.
How do I configure connection timeouts and other options?
Connection timeouts and other connection options are configurable when you set up the session, which helps scripts fail fast instead of hanging on an unresponsive host. Set conservative timeouts for automation that runs under a scheduler or CI job. Review the README for the exact option names supported by your installed version.
How should I test code that uses mikemeier/php-ssh?
The object-oriented API is designed to be testable, so wrap the client behind a small interface in your application and mock that interface in unit tests. Keep a separate, optional integration test suite that runs against a disposable SSH server or container for real end-to-end checks. Unit tests should never depend on the ssh2 extension or live credentials, which keeps CI fast and portable.
How does mikemeier/php-ssh compare to phpseclib?
phpseclib implements SSH and SFTP in pure PHP, so it works without any extension and is easier to install on restricted hosting. mikemeier/php-ssh instead wraps the native ssh2 extension, giving you a lightweight client that relies on battle-tested C libraries but requires that extension to be present. Choose phpseclib when you cannot control the PHP build, and this package when ssh2 is already available and you want a smaller, simpler API.
Is mikemeier/php-ssh safe to use in production and still maintained?
Check the GitHub repository and Packagist release history for recent commits, open issues, and the version constraints you would pin in composer.json before adopting it. Because the library is a thin wrapper over the native ssh2 extension, most connection stability comes from libssh2 and your server configuration rather than from the wrapper itself. For production, pin a specific version, store keys outside the repository, and avoid enabling verbose logging that could leak credentials.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons