This library can be used to manage systemd services. Internally it uses the Symfony Process Component for running the systemctl command.
- PHP 5.6 or higher
systemdinstalled
Run the following composer command in your project:
composer require mjanser/systemctlExample usage:
$service = new SystemCtl\Service('my-service'); if ($service->isRunning()) { $service->stop(); } else { $service->start(); } $service->restart();By default the command systemctl will be executed with sudo. You can change that if you need.
SystemCtl\Service::setCommand('my-systemctl'); SystemCtl\Service::sudo(false);