Download the PHP package seld/signal-handler without Composer

On this page you can find all versions of the php package seld/signal-handler. 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 signal-handler

Signal Handler

A simple cross-platform1 signal handler.

1 Windows support is only possible on PHP 7.4+ and only supports catching SIGINT/SIGBREAK (ctrl+c / ctrl+break respectively). On older PHP versions it will simply silently fail to work on Windows so you can use it but signals will just interrupt PHP as if the library was not in use.

Continuous Integration

Usage

Note: To maximize cross-platform support all signals are available as constants on the SignalHandler class and it is recommended to use those instead of the PHP constants as the constants are not available on all platforms.

Default usage, listen to SIGTERM and SIGINT (i.e. Ctrl+C / ^C interrupts)

Nesting/stacking and unregistering signal handlers

If you create multiple SignalHandler instances they will be kept on a stack and only the top-most / last created one will be triggered when a signal comes in.

When you unregister the top one the previous one becomes active again, etc.

For this to work well however you need to make sure you properly unregister the signal handler when you are done with it. On PHP 8.0+ this is done automatically whenever the signal handler is garbage collected as the stack uses WeakReference instances to keep track of the handlers. On PHP 7 however you need to call $signal->unregister(); explicitly to remove it from the global handler stack.

Typically it would look something like this if you need PHP 7 support:

Listen to custom signals and reset the handler to handle the same signal multiple times

Passing in a PSR-3 Logger will make it log ->info('Received '.$signalName)

Passing in a callback you can react to the signal as well

Warning: As described above on PHP 8.0+ this library uses weak references to keep track of the handlers, so if you do not store the result of ::create() into a variable that you keep around as long as you need the handler, it will not work and your callback function will never be called.

Installation

For a quick install with Composer use:

$ composer require seld/signal-handler

Requirements

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Jordi Boggiano - http://twitter.com/seldaek

License

signal-handler is licensed under the MIT License - see the LICENSE file for details


All versions of signal-handler with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
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 seld/signal-handler contains the following files

Loading the files please wait ....