PHPackages                             anexia/zf2-monitoring - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. anexia/zf2-monitoring

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

anexia/zf2-monitoring
=====================

A zf2 module to monitor runtime (php, zf2) versions, composer package versions and composer package licences

1.3.0(8y ago)0140MITPHP

Since Aug 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/anexia-it/anexia-monitoring-zf2)[ Packagist](https://packagist.org/packages/anexia/zf2-monitoring)[ RSS](/packages/anexia-zf2-monitoring/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (1)Versions (4)Used By (0)

Anexia Monitoring
=================

[](#anexia-monitoring)

A Zend Framework 2 plugin used to monitor updates for core and composer packages. It can be also used to check if the website is alive and working correctly.

Installation and configuration
------------------------------

[](#installation-and-configuration)

Install the module via composer, therefore adapt the `require` part of your `composer.json`:

```
"require": {
    "anexia/zf2-monitoring": "1.3.0"
},

```

In the projects `application.config.php` add the new module:

```
return array(
    'modules' => array(
        'Anexia\Monitoring'
    )
);

```

In the projects `local.php` config file add the access token configuration:

```
return array(
    'ANX_MONITORING_ACCESS_TOKEN' => ''
);

```

In the projects `local.php` config file add the database connection configuration:

```
return array(
    'db' => array(
        'host' => '', // e.g. localhost
        'username' => '',
        'password' => '',
        'database' => '',
        'driver' => '', // e.g. 'mysql',
        'dns' => 'mysql:dbname=;host='
    )
);

```

Usage
-----

[](#usage)

The module registers some custom REST endpoints which can be used for monitoring. Make sure that the **ANX\_MONITORING\_ACCESS\_TOKEN** is defined, since this is used for authorization. The endpoints will return a 401 HTTP\_STATUS code if the token is not defined or invalid, or will return a 200 HTTP\_STATUS code if everything went well.

### Version monitoring of core and composer packages

[](#version-monitoring-of-core-and-composer-packages)

Returns all a list with platform and composer package information.

**URL:** `/anxapi/v1/modules?access_token=custom_access_token`

Response headers:

```
Status Code: 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Allow: GET
Content-Type: application/json

```

Response body:

```
{
   "runtime":{
         "platform":"php",
         "platform_version":"7.0.19",
         "framework":"laravel",
         "framework_installed_version":"5.4.28",
         "framework_newest_version":"5.4.28"
      },
      "modules":[
         {
            "name":"package-1",
            "installed_version":"3.1.10",
            "installed_version_licences":[
               "BSD-2-Clause"
            ],
            "newest_version":"3.3.2",
            "newest_version_licences":[
               "BSD-3-Clause"
            ]
         },
         {
            "name":"package-2",
            "installed_version":"1.4",
            "installed_version_licences":[
               "MIT"
            ],
            "newest_version":"1.4",
            "newest_version_licences":[
               "MIT"
            ]
         },
         ...
      ]
}

```

### Live monitoring

[](#live-monitoring)

This endpoint can be used to verify if the application is alive and working correctly. It checks if the database connection is working. It allows to register custom checks by using hooks.

**URL:** `/anxapi/v1/up?access_token=custom_access_token`

Response headers:

```
Status Code: 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Allow: GET
Content-Type: text/plain

```

Response body:

```
OK

```

**Custom up check failure (without custom error message):**

Response headers (custom check failed without additional error message):

```
Status Code: 500 Internal Server Error
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Allow: GET
Content-Type: text/plain

```

Response body (containing default error message):

```
ERROR

```

**Custom up check failure (with custom error message):**

Response headers (custom check failed without additional error message):

```
Status Code: 500 Internal Server Error
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Allow: GET
Content-Type: text/plain

```

Response body (containing custom error message):

```
This is an example for a custom db check error message!

```

### Custom up check

[](#custom-up-check)

The `anexia/zf2-monitoring` only checks the DB connection / DB availability. To add further up checks a customized service can be defined. This service must implement the `Anexia\Monitoring\Service\UpCheckServiceInterface` and must be available as `Anexia\Monitoring\Service\UpCheck`. Therefore two steps are necessary:

1. Add a new service class (and its factory) to the project source code tree, e.g.:

```
