PHPackages                             consik/yii2-daemons - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. consik/yii2-daemons

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

consik/yii2-daemons
===================

Yii2 extension for creating PHP daemons with systemd units

1.0.1(9y ago)0558MITPHP

Since Jan 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/consik/yii2-daemons)[ Packagist](https://packagist.org/packages/consik/yii2-daemons)[ RSS](/packages/consik-yii2-daemons/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Yii2 daemons by systemd
=======================

[](#yii2-daemons-by-systemd)

[![Latest Stable Version](https://camo.githubusercontent.com/f048acce3dacf1ba3803c0773c9dcfecf9937ddfac7cc5846a2955bd479c4942/68747470733a2f2f706f7365722e707567782e6f72672f636f6e73696b2f796969322d6461656d6f6e732f762f737461626c65)](https://packagist.org/packages/consik/yii2-daemons)[![Total Downloads](https://camo.githubusercontent.com/fa2af1381879284728b8f69512e0ad61d06d12a097db129923074c0151becd7f/68747470733a2f2f706f7365722e707567782e6f72672f636f6e73696b2f796969322d6461656d6f6e732f646f776e6c6f616473)](https://packagist.org/packages/consik/yii2-daemons)[![License](https://camo.githubusercontent.com/70102f9746a65d7a65fb0b1c9c8d48d2c21a3a22091bef52bea01f71463273d1/68747470733a2f2f706f7365722e707567782e6f72672f636f6e73696b2f796969322d6461656d6f6e732f6c6963656e7365)](https://packagist.org/packages/consik/yii2-daemons)

Introduction
------------

[](#introduction)

There is no concrete realization for daemonizing PHP scripts by using pcntl\_fork() or something else. We don't need it, when we have package like systemd that can make service from our PHP script. So, there is DaemonInterface in package that has only two methods startDaemon() and stopDaemon(), and one AbstractLoopDaemon that implements this interface.

You can use your own script, that working in background, just implement there DaemonInterface.

All functions that makes daemon from your PHP script will do systemd and ServiceController.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require consik/yii2-daemons

```

or add

```
"consik/yii2-daemons": "^1.0"
```

Creating daemon.
----------------

[](#creating-daemon)

As I say above all that you need is to implement DaemonInterface.

Simple looped daemon:

```
