Download the PHP package net_bazzline/component_heartbeat without Composer

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

PHP Component Heartbeat

php component heartbeat provides interfaces and abstract implementations to provide a generic code base.

You should use this to implement your real heartbeat monitoring solution.

The build status of the current master branch is tracked by Travis CI: Build Status

Common Terms

@todo

Basic Concept

The heartbeat is divided into two components, the heartbeat client and the heartbeat monitor.

The main idea is to provide a heartbeat over parallel running threads or on different locations.

Both components are designed to be used on the monitor (observer) as well as on the heartbeat (client) side.

You should create process that uses the monitor that knocks attached heartbeats. The heartbeat is used in the monitor to knock and is used in the process to beat. The beat is called in the process and updates the status informations. The knock reads the status information and provides it to the monitor (if needed). The knock also throws an exception. If an exception occures, the monitor has to call the heartbeat method handleHeartAttack since the heartbeat itself only knows what to do and how to do.
The heartbeat can implement a PulseableInterface. This can be used to call the heartbeat only every $x seconds. How to handle a call below the pulse can be implemented in the heartbeat. To call the heartbeat in an interval with a minimum of the provided pulse is a gentleman agreement between the monitor and the heartbeat.

Heartbeat Client

The heartbeat itself has a beat method. This should be called as often as necessary to update the heartbeat information. If you iterate over a chunk of items, simple call the beat after each or after ten processed items.

Furthermore, the heartbeat knows where to look for the information and how to return the values to the monitor. This part has to be handled in the knock method.

Heartbeat Monitor

The heartbeat monitor provides attach and detach mechanisms for a heartbeat. The only thing you need to do is, to implement a way to store the attached heartbeats in a persistent way (database, filesystem, session).

Additional Interfaces

The component also declares a PulseableInterface as well as a RuntimeInformationInterface. Both can be used to retrieve data from the heartbeat (client).

Workflow

From The Perspective Of The Supervised Process (The Client)

The process would instantiate the heartbeat and the monitor. The monitor is used to attach the heartbeat (meaning, adding the heartbeat to the list of observable heartbeats). After that and depending on the heartbeat implementation in the process, the heartbeat would be used to update the status by calling the beat method. If the process is finished, it would use the monitor to detach the heartbeat from the list of observable heartbeats.

From The Perspective Of The Monitor (The Observer)

The monitor would take a look to the attached heartbeat clients and tries to knock each heartbeat. If the knock method of the heartbeat returns nothing or throws an exception, the monitor needs to take care. It is recommended to use the heartbeat method handleHeartAttack. This method should take care of cleaning up a died process.

What Do You Need To Do

PHP scripts are executed by a request. PHP itself is not designed for long running process. This leads to the fact that you are using the forking or threading mechanism of your webserver. How to keep track of your threads is your business.

A Possible Implementation

How to solve the communication between threads?

You have to implement a reachable data transfer object. For example, you can use a file, a database table or a session storage.

Using The Filesystem

A simple idea would be, to use the filesystem. The heartbeat would create a file with a unique but identifiable name. The file contains all needed information's. For example a json file could have the following layout.

From the side of the monitor, the heartbeat would read the file content and return the right one to the monitor.

Using The Database

To prevent read-/writelocks or multiple files across the file system you can use a database table that holds the information. A simple example is following.

Examples

JSON Based Implementation

php example/Example/JSONBasedImplementation/Example.php

JSON Base Implementation With Process Forking

php example/Example/JSONAndFork/Example.php

Investigate code if you want to.

Install

Via Git

cd my/path/to/other/git/repositories
mkdir -p stevleibelt/php_component_heartbeat/
cd stevleibelt/php_component_heartbeat
git clone https://github.com/stevleibelt/php_component_heartbeat .

Via Composer

require "net_bazzline/component_heartbeat": "dev-master"

To Do

Version History


All versions of component_heartbeat with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
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 net_bazzline/component_heartbeat contains the following files

Loading the files please wait ....