Your first server & apps

How to setup the server

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
$server = new Whisp\Server(port: 2020, host: '0.0.0.0');
$server->run(); // Auto discovery of apps
    

What are apps?

They're simply CLI PHP scripts that read from STDIN and write to STDOUT.

This can be basic PHP, or use Laravel Prompts, or use anything else you'd like.

Whisp makes them available over SSH by piping the SSH client through to your app & back, and you can register as many as you like.

How to register apps

You can register apps in 1 of 3 ways: auto discovery, array, or string.

default is a special app which we fallback to if no app is provided.

Auto Discovery

Whisp will find all lowercase files in the apps/ directory and register them as apps based on their filename.

        
        
        $server->run();
    

Array

Full paths are needed, and you can set 'default' to the same path if you'd like to fallback to a specific app.

        
        
        $server->run(apps: [
    'default' => 'full-path/howdy.php',
    'guestbook' => 'full-path/guestbook.php',
    'chat-{roomName}' => 'full-path/chat.php',
]);
    

String

This will only set the default app so will be used for all requests.

        
        
        $server->run('full-path/howdy.php');