PHPackages                             magnusjt/socketty - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. magnusjt/socketty

ActiveProject[Utility &amp; Helpers](/categories/utility)

magnusjt/socketty
=================

SSH terminal over web sockets

1.0.0(10y ago)8771MITJavaScript

Since Aug 24Pushed 10y ago3 watchersCompare

[ Source](https://github.com/magnusjt/socketty)[ Packagist](https://packagist.org/packages/magnusjt/socketty)[ RSS](/packages/magnusjt-socketty/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

socketty
========

[](#socketty)

Interactive terminals over websockets with a php backend. It can for instance be used to create interactive SSH sessions, but should work with any command. At the same time, an existing php backend can be used to perform authorization and authentication.

Uses the following tech:

- ratchet - Websockets with PHP
- reactphp - Async IO in PHP through an event loop
- term.js - Terminal emulation in the browser
- reactjs - For the rest of the UI
- python's pty module - For emulating a pty which php can interact with using normal pipes

[![alt tag](https://camo.githubusercontent.com/ac0d0b34ae45b4bdb9e67bdc7b07bd1756781a9d5875f8976872930584e07a83/68747470733a2f2f7261772e6769746875622e636f6d2f6d61676e75736a742f736f636b657474792f6d61737465722f65782e706e67)](https://camo.githubusercontent.com/ac0d0b34ae45b4bdb9e67bdc7b07bd1756781a9d5875f8976872930584e07a83/68747470733a2f2f7261772e6769746875622e636f6d2f6d61676e75736a742f736f636b657474792f6d61737465722f65782e706e67)

### Usage

[](#usage)

The project consists of a PHP backend which manages the client connections, and a frontend which emulates the terminal. In order to run the backend server, create a composer dependency on this project, and follow the example in `./server.php`:

```
composer require magnusjt/socketty

```

Here you can customize:

- Authentication - Implement the AuthenticatorInterface. If you want to reuse sessions from an existing site, you will need to do this through memcached
- Authorization - Same as Authentication, but in this case you may also authorize the command and command arguments.
- Port to use for websockets
- Allowed hosts
- Logging - The project uses the psr LoggerInterface, so anything goes (Monolog is a nice option)
- Spawner - Generates a command string to be executed. Commands can be enabled and disabled here.

Backend example: See `./server.php`

Frontend: Install by adding the following to npm dependencies: `"socketty": "git://github.com/magnusjt/socketty.git#master"`

Frontend example (needs to be compiled with browserify and babelify):

```
var Socketty = require('socketty');
var domNodeId = 'app'; // ID of the dom node to open the app in
var wssUrl = 'wss://localhost:5678'; // Websocket URL

// Create some presets
var opts = [
    {
        name: 'SSH',
        open: true,
        list: [
            {cmd: 'ssh vagrant@127.0.0.1', 'name': 'Vagrant SSH'},
        ]
    },
    {
        name: 'Ping',
        open: false,
        list: [
            {cmd: 'ping 127.0.0.1', 'name': 'Ping localhost'},
        ]
    }
];

Socketty.start(domNodeId, wssUrl, opts);

```

### Development

[](#development)

- Install frontend dependencies with `npm install`.
- Install backend dependencies with `composer install`
- Copy and rename a Vagrantfile and vagrant\_bootstrap.sh file
- Start virtual server with `vagrant up`
- Start websocket server with `php server.php`
- Open browser and go to  to pretend to login
- Open browser and go to  and spawn some terminals into the virtual server
- Build frontend stuff with `gulp build` and `gulp watchify`
- NB: apache and haproxy may need to be started manually after a reboot:

```
service httpd start
/usr/local/sbin/haproxy -f /vagrant/haproxy.cfg -p /var/run/haproxy.pid -D

```

### About SSL

[](#about-ssl)

In order to have secure web sockets, the vagrant install includes haproxy which terminates all ssl requests.

### How it works

[](#how-it-works)

First of all, reactphp is used together with an event loop to acheive async calls with PHP. A sub component of reactphp called child-processes uses PHP's proc\_open to connect to a child process and its pipes. For programs that require a tty (such as ssh and its interactive password prompt), we would really like to use PHP's pty pipes, but these are sadly not available on most systems. To get around this, all comands are opened through a python script, which uses the pty module to simulate a pty.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

3921d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0078388acec827c3aa742b3d4c464570b8957d2307de9278db3f9c077b78f751?d=identicon)[magnusjt](/maintainers/magnusjt)

---

Top Contributors

[![magnusjt](https://avatars.githubusercontent.com/u/5463727?v=4)](https://github.com/magnusjt "magnusjt (61 commits)")

---

Tags

ssh web-sockets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/magnusjt-socketty/health.svg)

```
[![Health](https://phpackages.com/badges/magnusjt-socketty/health.svg)](https://phpackages.com/packages/magnusjt-socketty)
```

###  Alternatives

[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[j0k3r/php-readability

Automatic article extraction from HTML

186808.8k6](/packages/j0k3r-php-readability)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[symfony/ai-agent

PHP library for building agentic applications.

30536.7k44](/packages/symfony-ai-agent)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)

PHPackages © 2026

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