Skip to content

Commit ffe5092

Browse files
committed
Add more information to README
1 parent 17628dd commit ffe5092

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

README.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
11
# systemctl-php
22
[![Build Status](https://api.travis-ci.org/icanhazstring/systemctl-php.svg?branch=master)](https://travis-ci.org/icanhazstring/systemctl-php) [![Code Climate](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/gpa.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php) [![Test Coverage](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/coverage.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php/coverage)
33

4-
> WORK IN PROGRESS
5-
6-
PHP wrapper for systemctl (PHP7.1)
4+
PHP wrapper for systemctl
75

86
# Table of Contents
97

8+
- [How to install](#how-to-install)
109
- [Static Methods](#static-methods)
11-
- [::setBinary(string $binary)](#setbinarystring-binary)
12-
- [::setTimeout(int $timeout)](#settimeoutint-timeout)
13-
- [::setInstallPath(string $installPath)](#setinstallpathstring-installpath)
14-
- [::setAssetPath(string $assetPath)](#setassetpathstring-assetpath)
10+
- [::setBinary](#setbinarystring-binary)
11+
- [::setTimeout](#settimeoutint-timeout)
12+
- [::setInstallPath](#setinstallpathstring-installpath)
13+
- [::setAssetPath](#setassetpathstring-assetpath)
1514
- ["I need sudo to run commands"](#i-need-sudo-to-run-commands)
1615
- [Managing units](#managing-units)
1716
- [Supported units](#supported-units)
18-
- [Handling unit commands](#handling-unit-commands)
17+
- [Unit commands](#unit-commands)
1918
- [Install new units](#install-new-units)
2019
- [UnitSection](#unitsection)
2120
- [InstallSection](#installsection)
2221
- [TypeSpecificSection](#typespecificsection)
22+
- [UnitInstaller](#unitinstaller)
2323
- [How to Contribute](#how-to-contribute)
2424

25+
# How to install
26+
```php
27+
$ composer require icanhazstring/systemctl-php
28+
```
29+
2530
# Static Methods
2631
### ::setBinary(string $binary)
2732
Change the binary executable of `SystemCtl`
2833

34+
> Default: /bin/systemctl
35+
2936
```php
3037
SystemCtl::setBinary('/bin/systemctl');
3138
```
3239

3340
### ::setTimeout(int $timeout)
3441
Change the timeout for each command like `start()` on units and `SystemCtl`
3542

43+
> Default: 3
44+
3645
```php
3746
SystemCtl::setTimeout(3);
3847
```
3948

4049
### ::setInstallPath(string $installPath)
4150
Change the install path for new units
4251

52+
> Default: /etc/systemd/system
53+
4354
```php
4455
SystemCtl::setInstallPath('/etc/systemd/system');
4556
```
@@ -48,6 +59,8 @@ SystemCtl::setInstallPath('/etc/systemd/system');
4859
Change the asset path to look for unit file templates.
4960
The `default` path is relative to the `SystemCtl` vendor package
5061

62+
> Default: assets
63+
5164
```php
5265
SystemCtl::setAssetPath('assets');
5366
```
@@ -65,7 +78,7 @@ To manage any unit u want simply use the proper getter to receive an `Unit` obje
6578

6679
> If you like to see more units feel free to contribute. Other units will be added in the future.
6780
68-
## Handling unit commands
81+
## Unit commands
6982
Each unit comes with a range of methods you can invoke on them (like `start()`).
7083
These methods will be dispatched to the `SystemCtl::$binary` you set before hand (or default).
7184

@@ -125,12 +138,26 @@ Each unit will have a type specific section. These sections are named after the
125138
To change them, you simply to the same thing as for the others. In case of a `Service` you will do
126139
the following:
127140

128-
> For a full documentation on available methods see [Serviceection](src/Template/Section/ServiceSection.php)
141+
> For a full documentation on available methods see [ServiceSection](src/Template/Section/ServiceSection.php)
129142
130143
```php
131144
$unitTemplate->getServiceSection()->setType(ServiceSection::TYPE_SIMPLE);
132145
```
133146

147+
## UnitInstaller
148+
To install an new unit, you need to pass the created `UnitTemplate` into `install()`
149+
of `SystemCtl`. This will use the internal `UnitInstaller` to create a unit file located at
150+
`/etc/systemd/system` by default. The `install()` method will also trigger a `daemon-reload` for
151+
systemd. This is needed to load the newly installed unit. Also you will receive an
152+
instance of the new unit you created, so you can manage the behavior of it (e.g. start())
153+
154+
```php
155+
$systemCtl = new SystemCtl;
156+
$unit = $systeCtl->install($unitTemplate);
157+
158+
$unit->start();
159+
```
160+
134161
# How to Contribute
135162
Simply clone the repo and install using `composer`
136163

0 commit comments

Comments
 (0)