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\Chunk,
Server\Process\Output\Type,
Server\Process\Pid,
Server\Signal,
Server\Volumes\Name,
};
use Innmind\TimeContinuum\Clock;
use Innmind\TimeWarp\Halt\Usleep;
use Innmind\IO\IO;
use Innmind\Url\Path;
use Innmind\Immutable\Str;
$server = ServerFactory::build(
Clock::live(),
IO::fromAmbientAuthority(),
Usleep::new(),
);
$server
->processes()
->execute(
Command::foreground('bin/console')
->withArgument('debug:router')
)
->unwrap()
->output()
->foreach(static function(Chunk $chunk): void {
$type = match ($chunk->type()) {
Type::error => 'ERR : ',
Type::output => 'OUT : ',
};
echo $type.$chunk->data()->toString();
});
$server
->processes()
->kill(
new Pid(42),
Signal::kill,
)
->unwrap();
$server
->volumes()
->mount(new Name('/dev/disk2s1'), Path::of('/somewhere')) // the path is only interpreted for linux
->unwrap();
$server
->volumes()
->unmount(new Name('/dev/disk2s1'))
->unwrap();
$server->reboot()->unwrap();
$server->shutdown()->unwrap();