Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHP wrapper for systemctl

License

NotificationsYou must be signed in to change notification settings

icanhazstring/systemctl-php

Repository files navigation

CI PipelineCode ClimateTest CoverageJoin the chat at https://gitter.im/icanhazstring/systemctl-php

PHP wrapper for systemctl

How to install

$ composer require icanhazstring/systemctl-php

Current supported units

SeeUnits

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

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

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

How to change command timeout

To change command tmeout simply call the static methodsetTimeout.

SystemCtl::setTimeout(10);

The default timeout is set to3 seconds

"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?

Simply is that. First we instantiate aSystemCtl instance an load a unit from a specific type. Here we use aService. You will always get backtrue if the command succeeded. Otherwise the method will throw aCommandFailedException.

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

How to Contribute

Clone the repo and install usingcomposer

$ composer install

Make your changes and make sure you runtest,codesniffer andphpstan.

$ composertest> vendor/bin/phpunitPHPUnit 9.5.3 by Sebastian Bergmann and contributors................................................................  63 / 128 ( 49%)............................................................... 126 / 128 ( 98%)..                                                              128 / 128 (100%)Time: 00:00.033, Memory: 10.00 MBOK (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-progressNote: Using configuration file /data/systemctl-php/phpstan.neon. [OK] No errors$

Credits

This library is heavily influenced by@mjanserphp-systemctl.


[8]ページ先頭

©2009-2025 Movatter.jp