PHPackages                             icanhazstring/systemctl-php - 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. icanhazstring/systemctl-php

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

icanhazstring/systemctl-php
===========================

PHP wrapper for systemctl

0.8.3(3y ago)7318.5k↓52%14[3 issues](https://github.com/icanhazstring/systemctl-php/issues)1MITPHPPHP ^7.3|^8.0CI failing

Since May 23Pushed 3y ago5 watchersCompare

[ Source](https://github.com/icanhazstring/systemctl-php)[ Packagist](https://packagist.org/packages/icanhazstring/systemctl-php)[ RSS](/packages/icanhazstring-systemctl-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (22)Used By (1)

systemctl-php
=============

[](#systemctl-php)

[![CI Pipeline](https://github.com/icanhazstring/systemctl-php/workflows/CI%20Pipeline/badge.svg)](https://github.com/icanhazstring/systemctl-php/workflows/CI%20Pipeline/badge.svg) [![Code Climate](https://camo.githubusercontent.com/ca08723309302fd7eb24ac996644734081ad13702e591d08f3391179f206169f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6963616e68617a737472696e672f73797374656d63746c2d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/icanhazstring/systemctl-php) [![Test Coverage](https://camo.githubusercontent.com/4322ecbd61a657911a4d7da8353d29852423c1f9951e71bdd4982ca57a481740/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6963616e68617a737472696e672f73797374656d63746c2d7068702f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/icanhazstring/systemctl-php/coverage) [![Join the chat at https://gitter.im/icanhazstring/systemctl-php](https://camo.githubusercontent.com/dc8e2dc1a3dfa5303cec86741fab9d76f2fc961141c27628ef5ff9d5494ecef6/68747470733a2f2f6261646765732e6769747465722e696d2f6963616e68617a737472696e672f73797374656d63746c2d7068702e737667)](https://gitter.im/icanhazstring/systemctl-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

PHP wrapper for systemctl

How to install
==============

[](#how-to-install)

```
$ composer require icanhazstring/systemctl-php
```

Current supported units
-----------------------

[](#current-supported-units)

See [Units](src/Unit)

> If you like to add support for more units, feel free to grab an issue and contribute.

Current supported commands
--------------------------

[](#current-supported-commands)

- start
- stop
- enable
- disable
- reload
- restart
- isEnabled
- isActive

> If you like to add support for more commands, feel free to contribute.

How to change the binary
------------------------

[](#how-to-change-the-binary)

```
SystemCtl::setBinary('/bin/systemctl');
```

How to change command timeout
-----------------------------

[](#how-to-change-command-timeout)

To change command tmeout simply call the static method `setTimeout`.

```
SystemCtl::setTimeout(10);
```

> The default timeout is set to `3` seconds

"I need sudo to run commands"
-----------------------------

[](#i-need-sudo-to-run-commands)

If you need sudo, you should execute the bin executable with sudo. The incode support was dropped due to security reason.

How do I start/stop/restart a unit?
-----------------------------------

[](#how-do-i-startstoprestart-a-unit)

Simply is that. First we instantiate a `SystemCtl` instance an load a unit from a specific type. Here we use a `Service`. You will always get back `true` if the command succeeded. Otherwise the method will throw a `CommandFailedException`.

```
$systemCtl = new SystemCtl();

// start/stop/enable/disable/reload/restart
$systemCtl->getService('nginx')->start();
$systemCtl->getService('nginx')->stop();
```

How to Contribute
=================

[](#how-to-contribute)

Clone the repo and install using `composer`

```
$ composer install
```

Make your changes and make sure you run *test*, *codesniffer* and *phpstan*.

```
$ composer test
> vendor/bin/phpunit
PHPUnit 9.5.3 by Sebastian Bergmann and contributors.

...............................................................  63 / 128 ( 49%)
............................................................... 126 / 128 ( 98%)
..                                                              128 / 128 (100%)

Time: 00:00.033, Memory: 10.00 MB

OK (128 tests, 192 assertions)

$ composer cs
> vendor/bin/phpcs --standard=PSR2 src/ && vendor/bin/phpcs --standard=PSR2 tests/

$

$ composer analyse
> vendor/bin/phpstan analyse --no-progress
Note: Using configuration file /data/systemctl-php/phpstan.neon.

 [OK] No errors

$
```

Credits
=======

[](#credits)

This library is heavily influenced by [@mjanser](https://github.com/mjanser) [php-systemctl](https://github.com/mjanser/php-systemctl).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 53.1% 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 ~123 days

Recently: every ~249 days

Total

19

Last Release

1104d ago

Major Versions

v0.6 → v1.0-rc.12017-08-22

v0.6.1 → 1.0-rc22019-04-07

0.7.0 → 1.x-dev2020-02-18

PHP version history (5 changes)v0.1PHP ^7.1

1.0-rc2PHP &gt;=7.1.0

0.7.0PHP ^7.2

0.8.0PHP ^7.3

0.8.2PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd1997b796c59d155bbaedeffafd15f61ab16f2d469824d77859e9918931de47?d=identicon)[icanhazstring](/maintainers/icanhazstring)

---

Top Contributors

[![icanhazstring](https://avatars.githubusercontent.com/u/883543?v=4)](https://github.com/icanhazstring "icanhazstring (26 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (14 commits)")[![func0der](https://avatars.githubusercontent.com/u/529819?v=4)](https://github.com/func0der "func0der (5 commits)")[![Wirone](https://avatars.githubusercontent.com/u/600668?v=4)](https://github.com/Wirone "Wirone (1 commits)")[![marcingy](https://avatars.githubusercontent.com/u/192095?v=4)](https://github.com/marcingy "marcingy (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![RageZBla](https://avatars.githubusercontent.com/u/1196871?v=4)](https://github.com/RageZBla "RageZBla (1 commits)")

---

Tags

phpphp-systemctlphp-wrappersystemctlsystemctl-phpsystemdsystemd-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/icanhazstring-systemctl-php/health.svg)

```
[![Health](https://phpackages.com/badges/icanhazstring-systemctl-php/health.svg)](https://phpackages.com/packages/icanhazstring-systemctl-php)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.3k](/packages/friendsofphp-php-cs-fixer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[civicrm/civicrm-core

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

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[phpactor/phpactor

PHP refactoring and intellisense tool for text editors

1.9k17.1k1](/packages/phpactor-phpactor)

PHPackages © 2026

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