Download the PHP package shankao/daemonizer without Composer

On this page you can find all versions of the php package shankao/daemonizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package daemonizer

Daemonizer

This project aims to greatly simplify the creation of very lightweight system daemons in PHP, and hide the low-level details after a modern class-based interface.

Daemonizer implements a fast and simple main loop for you, so you don't need to take care of the details. A disadvantage of this is that you must let your class' run() function end from time to time (no infinite loops). Failing to do this will make your daemon unresponsive to external signals (i.e. sigterm)

Daemonizer uses a version of PEAR's System_Daemon internally. Find it here: kvz/system_daemon

A very simple example

Daemon that echoes a string once per second:

Find a sightly more complete example at https://github.com/shankao/Daemonizer/blob/master/example.php

About the PID location parameter

Sadly, using System_Daemon internally has its drawbacks. One of the most visible in Daemonizer is the way that the PID file location has to be indicated:

  1. It requires to have at least two backslashes to start. In our example, the first part of "././example/example.pid" is only used to refer to the current folder. This requirement is due to System_Daemon expecting PID's to be system-wide located, like in /var/run (see the two backslashes)
  2. It requires that, after the two slashes, comes a folder with the same name as the daemon's name. In the example before, the "example" folder part. The reason is the same: System_Daemon requires to follow a UNIX system-wide protocol for PID file locations.

This problems will be fixed with the depart from System_Daemon in the future

Customization functions

Call them for your Daemonizer object, before the call to run() to change some aspects of the daemon:

Set the function to call when the daemon receives a SIGTERM signal

Set the function to call when the daemon receives a SIGHUP signal

Force the daemon's UID to this one

Force the daemon's GID to this one

Set the function to call for logging

Set System_Daemon's logging level

Next steps

For next releases, I intend to keep the same functionality, without using System_Daemon internally, as its code has become old and bloated. Given that I intend to keep Daemonizer simple and lightweight, that last part is not good. Also, the PID location quirk is painful for a real-world project.


All versions of daemonizer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
ext-posix Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shankao/daemonizer contains the following files

Loading the files please wait ....