mjanser / systemctl
dev-master
2018-02-11 17:40 UTC
Requires
- php: >=7.1
- symfony/process: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2021-01-26 14:13:07 UTC
README
此库可以用来管理systemd服务。内部使用 Symfony Process Component 来执行 systemctl
命令。
要求
- PHP 7.0 或更高版本
systemd
已安装
安装
在您的项目中运行以下composer命令
composer require mjanser/systemctl
使用方法
示例用法
$service = new SystemCtl\Service('my-service'); if ($service->isRunning()) { $service->stop(); } else { $service->start(); } $service->restart();
默认情况下,systemctl
命令将以 sudo
执行。如果需要,您可以更改此设置。
SystemCtl\Service::setCommand('my-systemctl'); SystemCtl\Service::sudo(false);