1. Go to this page and download the library: Download innmind/operating-system 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 / operating-system example snippets
use Innmind\OperatingSystem\Factory;
$os = Factory::build();
use Innmind\Url\Path;
$adapter = $os->filesystem()->mount(Path::of('/var/data/'));
use Innmind\Server\Control\Server\Command;
$process = $os
->control()
->processes()
->execute(Command::foreground('echo foo'));
use Innmind\Socket\Internet\Transport;
use Innmind\IP\IPv4;
use Innmind\Url\Authority\Port;
$server = $os
->ports()
->open(
Transport::tcp(),
IPv4::localhost(),
Port::of(1337),
)
->match(
static fn($server) => $server->unwrap(),
static fn() => throw new \RuntimeException('Cannot open the socket'),
);
# process A
use Innmind\Socket\Address\Unix;
$server = $os->sockets()->open(Unix::of('/tmp/foo.sock'))->match(
static fn($server) => $server->unwrap(),
static fn() => throw new \RuntimeException('Cannot open the socket'),
);
# process B
use Innmind\Socket\Address\Unix;
$client = $os->sockets()->connectTo(Unix::of('/tmp/foo.sock'))->match(
static fn($client) => $client->unwrap(),
static fn() => throw new \RuntimeException('Cannot connect to the socket'),
);
use Innmind\Url\Url;
use Innmind\Server\Control\Server\Command;
$process = $os
->remote()
->ssh(Url::of('ssh://user@server-address:1337'))
->processes()
->execute(Command::foreground('ls'));
use Innmind\Http\{
Message\Request\Request,
Message\Method,
ProtocolVersion,
};
use Innmind\Url\Url;
$response = $os
->remote()
->http()(new Request(
Url::of('http://example.com'),
Method::get,
ProtocolVersion::v20,
));
$os->process()->id();
use Innmind\TimeContinuum\Earth\Period\Minute;
$os->process()->halt(new Minute(1));
use Innmind\Signals\Signal;
$os->process()->signals()->listen(Signal::terminate, function() {
// handle the signal here
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.