2017 © Pedro Peláez
 

library systemctl-php

PHP wrapper for systemctl

image

icanhazstring/systemctl-php

PHP wrapper for systemctl

  • Thursday, July 19, 2018
  • by icanhazstring
  • Repository
  • 2 Watchers
  • 18 Stars
  • 2,102 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 10 Open issues
  • 11 Versions
  • 20 % Grown

The README.md

systemctl-php

CI Pipeline Code Climate Test Coverage Join the chat at https://gitter.im/icanhazstring/systemctl-php, (*1)

PHP wrapper for systemctl, (*2)

How to install

$ composer require icanhazstring/systemctl-php

Current supported units

See Units, (*3)

If you like to add support for more units, feel free to grab an issue and contribute., (*4)

Current supported commands

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

If you like to add support for more commands, feel free to contribute., (*5)

How to change the binary

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

How to change command timeout

To change command tmeout simply call the static method setTimeout., (*6)

SystemCtl::setTimeout(10);

The default timeout is set to 3 seconds, (*7)

"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., (*8)

How do I start/stop/restart 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., (*9)

$systemCtl = new SystemCtl();

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

How to Contribute

Clone the repo and install using composer, (*10)

$ composer install

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

$ 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

This library is heavily influenced by @mjanser php-systemctl., (*12)

The Versions

03/06 2018

dev-master

9999999-dev

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

27/02 2018

0.x-dev

0.9999999.9999999.9999999-dev

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

22/08 2017

v1.0-rc.1

1.0.0.0-RC1

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

21/08 2017

v0.6

0.6.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

16/08 2017

v0.5

0.5.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

04/07 2017

v0.4

0.4.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

07/06 2017

v0.3.1

0.3.1.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

07/06 2017

v0.3

0.3.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

02/06 2017

v0.2

0.2.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

23/05 2017

v0.1

0.1.0.0

PHP wrapper for systemctl

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring