1. Go to this page and download the library: Download innmind/server-control library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
innmind / server-control example snippets
use Innmind\Server\Control\{
ServerFactory,
Server\Command,
Server\Process\Output\Type,
Server\Process\Pid,
Server\Signal,
Server\Volumes\Name,
};
use Innmind\TimeContinuum\Earth\Clock;
use Innmind\TimeWarp\Halt\Usleep;
use Innmind\Stream\Streams;
use Innmind\Url\Path;
use Innmind\Immutable\Str;
$server = ServerFactory::build(
new Clock,
Streams::fromAmbientAuthority(),
new Usleep,
);
$server
->processes()
->execute(
Command::foreground('bin/console')
->withArgument('debug:router')
)
->output()
->foreach(static function(Str $data, Type $type): void {
$type = match ($type) {
Type::error => 'ERR : ',
Type::output => 'OUT : ',
};
echo $type.$data->toString();
});
$server
->processes()
->kill(
new Pid(42),
Signal::kill,
);
$server->volumes()->mount(new Name('/dev/disk2s1'), Path::of('/somewhere')); // the path is only interpreted for linux
$server->volumes()->unmount(new Name('/dev/disk2s1'));
$server->reboot();
$server->shutdown();