Explore the docs at WhispPHP.com »
composer require whispphp/whisp
- PHP 8.1+
- FFI module installed and enabled
- pcntl module
- libsodium module
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
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 |
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
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
This was developed by Ashley Hindle. If you like it, please star it, share it, and let me know!
- Bluesky
- Website https://ashleyhindle.com