PHPackages                             savvii/ssh-tunnel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. savvii/ssh-tunnel

ActiveLibrary[HTTP &amp; Networking](/categories/http)

savvii/ssh-tunnel
=================

Small library to create an SSH tunnel, for example for MySQL

1.1.2(3y ago)42.1k↓67.3%2MITPHPPHP &gt;=8.0CI failing

Since Mar 8Pushed 3y ago4 watchersCompare

[ Source](https://github.com/Savvii/ssh-tunnel)[ Packagist](https://packagist.org/packages/savvii/ssh-tunnel)[ RSS](/packages/savvii-ssh-tunnel/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

[![Code Quality](https://github.com/Savvii/ssh-tunnel/actions/workflows/codeQuality.yml/badge.svg)](https://github.com/Savvii/ssh-tunnel/actions/workflows/codeQuality.yml)

Small library to create a SSH Tunnel
------------------------------------

[](#small-library-to-create-a-ssh-tunnel)

Example usage:

```
use Savvii\SshTunnel\SshTunnel;

$tunnel = new SshTunnel(
    sshUsername: 'myuser',
    sshHost: 'jumpserver.example.com',
    sshPort: 22,
    bindHost: 'remote-db-host.local.lan',
    bindPort: 3306
);

$db = new PDO(
    sprintf(
        "mysql:host=%s;port=%d",
        $tunnel->localAddress,
        $tunnel->localPort
    )
);
```

When the PHP script ends or the `SshTunnel` object is destroyed the SSH tunnel is disconnected.

### Warning

[](#warning)

When you create the object but let it go out of scope, by default the SSH tunnel will be cleaned up. This will not work:

```
function connect(): void
{
    $tunnel = new SshTunnel(...);
}

connect();
// At this point the SSH tunnel is disconnected because $tunnel went out of scope.
```

This will work:

```
function connect(): void
{
    return new SshTunnel(...);
}

$tunnel = connect();
// At this point the SSH tunnel works.
```

If you are creating the `SshTunnel` object in the constructor of a class, make sure to store it in a class property, to make it not go out of scope when the constructor is finished.

Requirements
------------

[](#requirements)

- Linux, MacOS or FreeBSD
- PHP 8.0 or greater
- PHP functions `proc_open`,`proc_close`,`proc_terminate` and `proc_get_status` enabled
- Binary `ssh`
- Binary `lsof`, used by default but can be skipped.
- Binary `nc`, used by default but can be skipped.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1213d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/658024?v=4)[Jeroen Vermeulen](/maintainers/jeroenvermeulen)[@jeroenvermeulen](https://github.com/jeroenvermeulen)

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/savvii-ssh-tunnel/health.svg)

```
[![Health](https://phpackages.com/badges/savvii-ssh-tunnel/health.svg)](https://phpackages.com/packages/savvii-ssh-tunnel)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M92](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
