PHPackages                             niladam/laravel-zabbix - 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. niladam/laravel-zabbix

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

niladam/laravel-zabbix
======================

A PHP &amp; Laravel zabbix sender and provider

1.1.4(12mo ago)1078MITPHPPHP &gt;=7.4 &lt;=8.4

Since Dec 30Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/niladam/laravel-zabbix)[ Packagist](https://packagist.org/packages/niladam/laravel-zabbix)[ RSS](/packages/niladam-laravel-zabbix/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (0)

[![Tests](https://github.com/niladam/laravel-zabbix/actions/workflows/run-tests.yml/badge.svg)](https://github.com/niladam/laravel-zabbix/actions/workflows/run-tests.yml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/158243a725e2aa868d45850bd8666c0630a14394d9d754fced45d0919cbed2e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e696c6164616d2f6c61726176656c2d7a61626269782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/niladam/laravel-zabbix)

Laravel Zabbix Integration
==========================

[](#laravel-zabbix-integration)

This package provides a seamless way to send metrics, alerts, and notifications to a Zabbix server within PHP &amp; Laravel applications. It includes powerful abstractions, support for named configurations, and simplified usage via `make` methods.

The package borrows code and is inspired by the [Zabbix sender](https://github.com/zarplata/zabbix-sender-php) package. Some credits go to [zarplata](https://github.com/zarplata).

---

Features
--------

[](#features)

- **PHP 7.4+ compatible.**: Works with PHP 7.4 and above.
- **Named Configurations**: Easily switch between multiple host configurations.
- **Streamlined Object Creation**: Utilize `make` methods to simplify object initialization.
- **ZabbixAlert Class**: Extendable class for effortless alerts.
- **Notification Channel**: Integrate Zabbix with Laravel's notification system.
- **Queue Support**: Fully compatible with Laravel queues.
- **Usage outside of Laravel**: Fully functional outside of Laravel.

---

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require niladam/laravel-zabbix
```

If using Laravel you can publish the config file with:

```
php artisan vendor:publish --provider="Niladam\LaravelZabbix\LaravelZabbixServiceProvider"
```

This creates `config/laravel-zabbix.php` with the following contents:

```
return [
    /**
     * Your Zabbix server hostname.
     *
     * Just the hostname of the server.
     */
    'server' => env('ZABBIX_SERVER'),

    /**
     * Your zabbix port.
     *
     * If different from the default 10051.
     */
    'port' => env('ZABBIX_PORT', 10051),

    /**
     * Available hosts.
     *
     * Eeach key in the hosts array must contain the host_name and key keys.
     */
    'hosts' => [
        'default' => [
            'host_name' => env('ZABBIX_DEFAULT_HOSTNAME'),
            'key' => env('ZABBIX_DEFAULT_KEY'),
        ],
    ],
];
```

---

Configuration
-------------

[](#configuration)

Define hosts and default server settings in `config/laravel-zabbix.php`:

```
return [
    'server' => env('ZABBIX_SERVER', '127.0.0.1'),
    'port' => env('ZABBIX_PORT', 10051),
    'hosts' => [
        'default' => [
            'host_name' => 'default-host',
            'key' => 'default-key',
        ],
        'critical' => [
            'host_name' => 'critical-host',
            'key' => 'critical-key',
        ],
    ],
];
```

Use named configurations like `default` or `critical` in your code.

---

Usage
-----

[](#usage)

### Creating and sending messages (or metrics)

[](#creating-and-sending-messages-or-metrics)

The `make` method simplifies message creation by preloading the configuration and injecting the `ZabbixManager`. Example:

```
use Niladam\LaravelZabbix\ZabbixManager;
use Niladam\LaravelZabbix\Communication\Message;
use Niladam\LaravelZabbix\Communication\Response;

$manager = app(ZabbixManager::class);

// Create a message with the 'critical' configuration
$criticalMessage = Message::make('critical')->usingValue('Service is down');
$someOtherMessage = Message::make('default')->usingValue('Just another message');

// Send the message
$manager
    ->add($criticalMessage)
    ->add($someOtherMessage);

$response = $manager->send(); // Returns a Response class.

// Some useful methods:
$response->getSummary();            // Get a summary
$response->getDuration();           // Get duration
$response->getTotalCount();         // Get total count
$response->getProcessedCount();     // Get processed count
$response->getFailedCount();        // Get failed count

// The summary looks like:
$summary = [
    "success" => true,
    "humanDuration" => "66 µs",
    "processed" => 1,
    "failed" => 0,
    "total" => 1,
    "duration" => 6.6E-5,
];

// You can also use the message directly:
$response = Message::make('critical')->usingValue('Service is down')->send();
```

Simplified Alerts with `ZabbixAlert`
------------------------------------

[](#simplified-alerts-with-zabbixalert)

The `ZabbixAlert` class is designed for quick and easy alert creation. Extend this class to define alerts with minimal effort.

```
namespace App\Alerts\Zabbix;

use Niladam\LaravelZabbix\Notifications\ZabbixAlert;

class MyZabbixAlert extends ZabbixAlert
{
    /**
     * @return string|array
     */
    public function getHostConfiguration()
    {
        // Returning a string assumes you have a named configuration.
        return 'my-host-configuration-key-from-config';

        // OR

        // Returning an array, will use the host details
        return [
            'host_name' => 'your-hostname',
            'key' => 'your-key',
        ];
    }

    // If you have a getMessage method on your alert, this will be used.
    public function getMessage(): string
    {
        return 'Oh noes, something happened!';
    }
}

use Illuminate\Support\Facades\Notification;

Notification::sendNow(User::system(), MyZabbixAlert::make('Oh yes, i have changed the message'));
Notification::route('zabbix','',)->notify(MyZabbixAlert::make('Oh yes, i have changed the message'));

// Or simply send it out.
MyZabbixAlert::make()->send();
```

Laravel Notifications
---------------------

[](#laravel-notifications)

Integrate Zabbix with Laravel notifications using the `ZabbixChannel`.

### Example Notification

[](#example-notification)

```
use Illuminate\Notifications\Notification;
use Niladam\LaravelZabbix\Communication\Message;
use Niladam\LaravelZabbix\Notifications\ZabbixChannel;

class ServerDownNotification extends Notification
{
    public function via($notifiable): array
    {
        return [ZabbixChannel::class];
    }

    public function toZabbix($notifiable): Message
    {
        return Message::make('default')->usingValue('Server is down');
    }
}
```

---

Advanced Usage
--------------

[](#advanced-usage)

```
use Niladam\LaravelZabbix\ZabbixManager;

$zabbix = app(ZabbixManager::class);

// List the configured hosts
$zabbix->availableHostNames();
$zabbix->getConfig(); // Get the configuration
```

### Temporary Configurations

[](#temporary-configurations)

For one-off configurations, use `usingServer`:

```
use Niladam\LaravelZabbix\ZabbixManager;
use Niladam\LaravelZabbix\Communication\Message;

$zabbix = app(ZabbixManager::class); // This uses the default server which will be overwritten below.

$zabbix->usingServer([
    'server' => 'temporary-server',
    'port' => 10052,
])
    ->add(
        Message::make()->usingValue('Temporary alert')
    )
    ->add(
        Message::make()
            ->usingHost('another-host')
            ->usingKey('different_key')
            ->usingValue('Something else')
   );

$zabbix->send();
```

---

### Usage outside of Laravel

[](#usage-outside-of-laravel)

```
require 'vendor/autoload.php';

use Niladam\LaravelZabbix\ZabbixManager;
use Niladam\LaravelZabbix\Communication\Message;

$configuration = [
    'server' => 'my-zabbix-server',
    'port' => 10051,
    'hosts' => [
        'default' => [
            'host_name' => 'my default host',
            'key' => 'the host key',
        ],
    ],
];

$manager = new ZabbixManager($configuration);

Message::setDefaultManager($manager);

$response = Message::make()->usingValue('test using single class')->send();

$response->getSummary();

// OR, multiple.

$manager->add(Message::make()->usingHost('another-host')->usingKey('some-key')->usingValue('test using multiple classes'));

$manager->add(Message::make()->usingConfigurationKey('default')->usingValue('test using configuration key'));

$manager->send();
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Madalin Tache](https://github.com/niladam)
- [Zarplata](https://github.com/zarplata)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance50

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~34 days

Total

6

Last Release

363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ccbd5f80c8e1c691272c1d4652e4da750d3ba4e08bcc2a8f9801f7f3aadf975?d=identicon)[niladam](/maintainers/niladam)

---

Top Contributors

[![niladam](https://avatars.githubusercontent.com/u/4151765?v=4)](https://github.com/niladam "niladam (15 commits)")

---

Tags

laravelphpzabbix

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/niladam-laravel-zabbix/health.svg)

```
[![Health](https://phpackages.com/badges/niladam-laravel-zabbix/health.svg)](https://phpackages.com/packages/niladam-laravel-zabbix)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
