PHPackages                             innmind/server-control - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. innmind/server-control

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

innmind/server-control
======================

Allows to control the server from php

7.1.0(3mo ago)0104.3k↓27.3%1[2 issues](https://github.com/Innmind/ServerControl/issues)8MITPHPPHP ~8.4CI passing

Since May 29Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Innmind/ServerControl)[ Packagist](https://packagist.org/packages/innmind/server-control)[ Docs](http://github.com/Innmind/ServerControl)[ RSS](/packages/innmind-server-control/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (41)Used By (8)

ServerControl
=============

[](#servercontrol)

[![CI](https://github.com/Innmind/ServerControl/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Innmind/ServerControl/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/ad37d63a5c796f62542043dea4e9e6f89e5ccbfbb9b8c29c0ebcddf87c386a3e/68747470733a2f2f636f6465636f762e696f2f67682f696e6e6d696e642f736572766572636f6e74726f6c2f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/innmind/servercontrol)[![Type Coverage](https://camo.githubusercontent.com/9811efdbdaad2346cfcfd433f361e1a26424920d512bfa66b26e5b3ff94db8b2/68747470733a2f2f73686570686572642e6465762f6769746875622f696e6e6d696e642f736572766572636f6e74726f6c2f636f7665726167652e737667)](https://shepherd.dev/github/innmind/servercontrol)

Give access to giving instructions to the server.

Important

To correctly use this library you must validate your code with [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm)

Installation
------------

[](#installation)

```
composer require innmind/server-control
```

Usage
-----

[](#usage)

```
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();
```

### Scripts

[](#scripts)

Sometimes you may want to run a set of commands on your server. You can easily do so like this:

```
use Innmind\Server\Control\Server\{
    Script,
    Command,
};

$script = Script::of(
    Command::foreground('apt-get install php-fpm -y'),
    Command::foreground('service nginx start'),
);
$script($server);
```

If any command fails, it will stop the script and raise an exception.

### Remote server control

[](#remote-server-control)

```
use Innmind\Server\Control\Servers\Remote;
use Innmind\Url\Authority\{
    Host,
    Port,
    UserInformation\User,
};

$server = Remote::of(
    $server,
    User::of('john'),
    Host::of('example.com'),
    Port::of(42),
);
$server
    ->processes()
    ->execute(Command::foreground('ls'))
    ->unwrap();
```

This will run `ssh -p 42 john@example.com ls`.

Important

Specifying environment variables or an input stream will not be taken into account on the remote server.

### Logging

[](#logging)

```
use Innmind\Server\Control\Servers\Logger;
use Psr\Log\LoggerInterface;

$server = Logger::psr($server, /** an instance of LoggerInterface */);
```

### Mocking

[](#mocking)

In order to simplify testing code this library exposes a `Mock` server that can be configured like this:

```
use Innmind\Server\Control\{
    Servers\Mock,
    Servers\Mock\ProcessBuilder,
    Server\Command,
    Server\Process\Output\Chunk,
    Server\Process\Output\Type,
};
use Innmind\Immutable\{
    Sequence,
    Str,
};
use Innmind\BlackBox\Runner\Assert;

$assert = /* an instance of Assert */;
$server = Mock::new($assert)
    ->willReboot()
    ->willFailToReboot()
    ->willShutdown()
    ->willFailToShutdown()
    ->willMountVolume('volumeName', '/mount/endpoint')
    ->willFailToMountVolume('volumeName', '/mount/endpoint')
    ->willUnmountVolume('volumeName')
    ->willFailToUnmountVolume('volumeName')
    ->willExecute(
        static fn(Command $command) => $assert->same(
            "echo 'foo'",
            $command->toString(),
        ),
        static fn(Command $command, ProcessBuilder $build) => $build->success(
            Sequence::of(Chunk::of(
                Str::of('foo'),
                Type::output,
            )),
        ),
    )
    ->willExecute(
        static fn(Command $command) => $assert->same(
            "echo 'foobar'",
            $command->toString(),
        ),
        static fn(Command $command, ProcessBuilder $build) => $build->success([
            ['foobar', 'output'],
        ]),
    );
```

Important

The order in which you call the `will*` methods is the order in which the code you test needs to make these actions.

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~86 days

Recently: every ~128 days

Total

38

Last Release

92d ago

Major Versions

2.8.3 → 3.0.02020-01-18

3.3.0 → 4.0.02022-02-19

4.3.0 → 5.0.02023-01-29

5.2.3 → 6.0.02025-04-21

6.1.0 → 7.0.02026-01-31

PHP version history (6 changes)1.0.0PHP ~7.1

3.0.0PHP ~7.4

3.2.0PHP ~7.4|~8.0

4.0.0PHP ~8.1

5.1.0PHP ~8.2

7.0.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (359 commits)")

### Embed Badge

![Health badge](/badges/innmind-server-control/health.svg)

```
[![Health](https://phpackages.com/badges/innmind-server-control/health.svg)](https://phpackages.com/packages/innmind-server-control)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[j0k3r/php-readability

Automatic article extraction from HTML

186808.8k6](/packages/j0k3r-php-readability)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
