Download the PHP package cruide/php-daemon-abstract without Composer

On this page you can find all versions of the php package cruide/php-daemon-abstract. 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 php-daemon-abstract

cruide/php-daemon-abstract

Abstract PHP daemon base class for Unix/Linux. Handles forking, detaching, PID management, signal handling, log rotation, and memory/repeat limits — so you only write the business logic.

Requirements

PHP Extensions

This package requires extensions that are not part of the default PHP distribution. They must be installed separately and are available only on Unix/Linux:

Extension Purpose Install (Debian/Ubuntu)
pcntl fork, signals, async dispatch apt install php-pcntl
posix setsid, process group, kill apt install php-posix
zlib gzip log rotation usually bundled with PHP

Verify with:

pcntl and posix will never work on Windows — the daemon is Unix/Linux only.

Installation

Quick start

Start: php daemon.php — the process forks to background.
Stop: kill $(cat /var/app/pids/daemon-*.pid)

DaemonConfig

All parameters have sensible defaults:

Parameter Default Description
workDir /phpd Base directory for pids/ and logs/ subdirectories
sleepSeconds 1 Sleep between loop iterations
maxRepeats 60 Max loop iterations (0 = unlimited)
maxMemoryMb 25 Max memory in MB before graceful stop (0 = unlimited)
errorStrategy ErrorStrategy::CONTINUE What to do on exception in process()
logRotateBytes 1048576 (1 MB) File size threshold for log rotation

DaemonInterface

Your daemon class must implement these 5 methods:

Method When it is called
process() Every loop iteration — your business logic goes here
processException(Throwable) When process() throws — log, alert, etc.
onStart() Once, before the main loop starts
onStop() Once, before the daemon exits (cleanup)
reload() On SIGHUP — reload config or state without restart

Error handling

Two strategies, configured via DaemonConfig::$errorStrategy:

Signal handling

Signal Action
SIGTERM Graceful stop (onStop → remove PID → exit)
SIGQUIT Same as SIGTERM
SIGHUP Calls reload() without restarting

Log management

PID file

More examples

See the examples/ directory:

License

MIT — see LICENSE.


All versions of php-daemon-abstract with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-pcntl Version *
ext-posix Version *
ext-zlib 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 cruide/php-daemon-abstract contains the following files

Loading the files please wait ...