whispphp / whisp
Pure PHP SSH server designed for terminal apps
1.0.0
2025-03-23 13:37 UTC
Requires
- php: ^8.2|^8.3|^8.4
- ext-pcntl: *
- ext-sodium: *
- phpseclib/phpseclib: ^3.0
- psr/log: ^3.0
Requires (Dev)
- laravel/pint: ^1.21
- pestphp/pest: ^3.7
README
Whisp
Your pure* PHP SSH server & the best way to build SSH based TUIs
Note
Quick example: sign our guestbook (See the code)
ssh guestbook@whisp.fyi
Explore the docs at WhispPHP.com »
Installation
composer require whispphp/whisp
Requirements
- PHP 8.1+
- FFI module installed and enabled
- pcntl module
- libsodium module
Usage
Run the server on the port & IP you'd like, with the apps you want to make available. Each connection is forked to its own process and runs independently.
<?php use Whisp\Server; $server = new Server(port: 2222); // Available apps - each is its own script forked $server->run(apps: [ 'default' => __DIR__.'/examples/howdy.php', 'guestbook' => __DIR__.'/examples/guestbook.php', ]); // $server->run('full-path/howdy.php'); // Pass just one path if you'd like to only support 1 default script
Once running you can test with:
Default app
ssh localhost -p2222
Guestbook app
ssh guestbook@localhost -p2222
Environment variables available to each app
These are each available as environment variables.
Variable | Description | Notes |
---|---|---|
WHISP_APP | The name of the app being requested | |
WHISP_CLIENT_IP | The IP address of the connecting client | |
WHISP_TTY | The TTY information for the connection | e.g. /dev/ttys072 |
WHISP_USERNAME | The username used in the SSH connection | Unavailable when no username passed, or when the username is a valid app |
Clients requesting apps
There are two ways for clients to request an available app:
- Username method:
ssh app@server
- we use the 'username' here as the app name if it matches an available app.- Much cleaner, but means if you need the username for auth you can't define the app this way
- Command method:
ssh server -t app
- request an interactive shell (-t
) with the requestedapp
Examples
Play the Dinorun game ∙ See the code
ssh dinorun@whisp.fyi
View your sunrise/sunset times ∙ See the code
ssh daylight@whisp.fyi
Find your closest World Heritage Sites
ssh elec@whisp.fyi
Support & Credits
This was developed by Ashley Hindle. If you like it, please star it, share it, and let me know!
- Bluesky
- Website https://ashleyhindle.com