PHPackages                             understand/understand-laravel4 - 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. understand/understand-laravel4

ActiveLibrary

understand/understand-laravel4
==============================

Laravel service provider for Understand.io

v0.0.15(6y ago)1621MITPHPPHP &gt;=5.3.0CI failing

Since Jul 25Pushed 6y ago4 watchersCompare

[ Source](https://github.com/understand/understand-laravel4)[ Packagist](https://packagist.org/packages/understand/understand-laravel4)[ RSS](/packages/understand-understand-laravel4/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (1)Versions (16)Used By (0)

Laravel 4 service provider for Understand.io
--------------------------------------------

[](#laravel-4-service-provider-for-understandio)

[![Build Status](https://camo.githubusercontent.com/9ca0a393336f9786186d1c22230bdade1f65d5a583905d69ef9c884dc866b03b/68747470733a2f2f7472617669732d63692e6f72672f756e6465727374616e642f756e6465727374616e642d6c61726176656c342e737667)](https://travis-ci.org/understand/understand-laravel4)[![Latest Stable Version](https://camo.githubusercontent.com/b7f2b22a1658db4b8cc21059975efc4511884027651d1774ff377d28948abc71/68747470733a2f2f706f7365722e707567782e6f72672f756e6465727374616e642f756e6465727374616e642d6c61726176656c342f762f737461626c652e737667)](https://packagist.org/packages/understand/understand-laravel4)[![Latest Unstable Version](https://camo.githubusercontent.com/225e4727b893c2315d8d828557f6c401320c8942f5aaeb256e98a940ed58d4ff/68747470733a2f2f706f7365722e707567782e6f72672f756e6465727374616e642f756e6465727374616e642d6c61726176656c342f762f756e737461626c652e737667)](https://packagist.org/packages/understand/understand-laravel4)[![License](https://camo.githubusercontent.com/597f89ebde6219afb346b056244a24a2b613cb2d75cbace89b9b013043f126a4/68747470733a2f2f706f7365722e707567782e6f72672f756e6465727374616e642f756e6465727374616e642d6c61726176656c342f6c6963656e73652e737667)](https://packagist.org/packages/understand/understand-laravel4)

> You may also be interested in our [Laravel 5, 6 or 7](https://github.com/understand/understand-laravel), [Laravel Lumen service provider](https://github.com/understand/understand-lumen) or [Monolog Understand.io handler](https://github.com/understand/understand-monolog)

### Introduction

[](#introduction)

This packages provides a full abstraction for Understand.io and provides extra features to improve Laravel's default logging capabilities. It is essentially a wrapper around Laravel's event handler to take full advantage of Understand.io's data aggregation and analysis capabilities.

### Quick start

[](#quick-start)

1. Add this package to your composer.json

    ```
    "understand/understand-laravel4": "0.0.*"
    ```
2. Update composer.json packages

    ```
    composer update

    ```
3. Add the ServiceProvider to the providers array in app/config/app.php

    ```
    'Understand\UnderstandLaravel\UnderstandLaravelServiceProvider',
    ```
4. Publish configuration file

    ```
    php artisan config:publish understand/understand-laravel

    ```
5. Set your input key in config file

    ```
    'token' => 'my-input-token'
    ```
6. Send your first event

    ```
    // anywhere inside your Laravel app
    \Log::info('Understand.io test');
    ```

### How to send events/logs

[](#how-to-send-eventslogs)

#### Laravel logs

[](#laravel-logs)

By default, Laravel automatically stores its logs in `app/storage/logs`. By using this package, your logs can also be sent to your Understand.io channel. This includes error and exception logs, as well as any log events that you have defined (for example, `Log::info('my custom log')`).

```
\Log::info('my message', ['my_custom_field' => 'my data']);
```

[Laravel logging documentation](http://laravel.com/docs/errors#logging)

#### PHP/Laravel exceptions

[](#phplaravel-exceptions)

By default, All exceptions will be send to Understand.io service.

#### Eloquent model logs

[](#eloquent-model-logs)

Eloquent model logs are generated whenever one of the `created`, `updated`, `deleted` or `restored` Eloquent events is fired. This allows you to automatically track all changes to your models and will contain a current model diff (`$model->getDirty()`), the type of event (created, updated, etc) and additonal meta data (user\_id, session\_id, etc). This means that all model events will be transformed into a log event which will be sent to Understand.io.

By default model logs are disabled. To enable model logs, you can set the config value to `true`:

```
'log_types' => [
    'eloquent_log' => [
        'enabled' => true,
```

### Additional meta data (field providers)

[](#additional-meta-data-field-providers)

You may wish to capture additional meta data with each event. For example, it can be very useful to capture the request url with exceptions, or perhaps you want to capture the current user's ID. To do this, you can specify custom field providers via the config.

```
/**
 * Specify additional field providers for each log
 * E.g. sha1 version session_id will be appended to each "Log::info('event')"
 */
'log_types' => [
    'eloquent_log' => [
        'enabled' => false,
        'meta' => [
            'session_id' => 'UnderstandFieldProvider::getSessionId',
            'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
            'user_id' => 'UnderstandFieldProvider::getUserId',
            'env' => 'UnderstandFieldProvider::getEnvironment',
            'client_ip' => 'UnderstandFieldProvider::getClientIp',
        ]
    ],
    'laravel_log' => [
        'enabled' => true,
        'meta' => [
            'session_id' => 'UnderstandFieldProvider::getSessionId',
            'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
            'user_id' => 'UnderstandFieldProvider::getUserId',
            'env' => 'UnderstandFieldProvider::getEnvironment',
        ]
    ],
    'exception_log' => [
        'enabled' => true,
        'meta' => [
            'session_id' => 'UnderstandFieldProvider::getSessionId',
            'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
            'user_id' => 'UnderstandFieldProvider::getUserId',
            'env' => 'UnderstandFieldProvider::getEnvironment',
            'url' => 'UnderstandFieldProvider::getUrl',
            'method' => 'UnderstandFieldProvider::getRequestMethod',
            'client_ip' => 'UnderstandFieldProvider::getClientIp',
            'user_agent' => 'UnderstandFieldProvider::getClientUserAgent'
        ]
    ]
]
```

The Understand.io service provider contains a powerful field provider class which provides default providers, and you can create or extend new providers.

```
dd(UnderstandFieldProvider::getSessionId());
// output: c624e355b143fc050ac427a0de9b64eaffedd606
```

#### Default field providers

[](#default-field-providers)

The following field providers are included in this package:

- `getSessionId` - return sha1 version of session id
- `getRouteName` - return current route name (e.g. `clients.index`).
- `getUrl` - return current url (e.g. `/my/path?with=querystring`).
- `getRequestMethod` - return request method (e.g. `POST`).
- `getServerIp` - return server IP.
- `getClientIp` - return client IP.
- `getClientUserAgent` - return client's user agent.
- `getEnvironment` - return Laravel environment (e.g. `production`).
- `getProcessIdentifier` - return unique token which is unique for every request. This allows you to easily group all events which happen in a single request.
- `getUserId` - return current user id. This is only available if you make sure of the default Laravel auth or the cartalyst/sentry package. Alternatively, if you make use of a different auth package, then you can extend the `getUserId` field provider and implement your own logic.

#### How to extend create your own methods or extend the field providers

[](#how-to-extend-create-your-own-methods-or-extend-the-field-providers)

```
UnderstandFieldProvider::extend('getMyCustomValue', function()
{
    return 'my custom value';
});

UnderstandFieldProvider::extend('getCurrentTemperature', function()
{
    return \My\Temperature\Provider::getRoomTemperature();
});
```

#### Example

[](#example)

Lets assume that you have defined a custom field provider called `getCurrentTemperature` (as above). You should then add this to your config file as follows:

```
    'laravel_log' => [
        'meta' => [
            ...
            'temperature' => 'UnderstandFieldProvider::getCurrentTemperature',
            ...
        ]
    ],
```

This additional meta data will then be automatically appended to all of your Laravel log events (`Log::info('my_custom_event')`), and will appear as follows:

```
{
  "message": "my_custom_event",
  "custom_temperature":"23"
}
```

### How to send data asynchronously

[](#how-to-send-data-asynchronously)

##### Async handler

[](#async-handler)

By default each log event will be sent to Understand.io's api server directly after the event happens. If you generate a large number of logs, this could slow your app down and, in these scenarios, we recommend that you make use of a async handler. To do this, change the config parameter `handler` to `async`.

```
/**
 * Specify which handler to use - sync, queue or async.
 *
 * Note that the async handler will only work in systems where
 * the CURL command line tool is installed
 */
'handler' => 'async',
```

The async handler is supported in most of the systems - the only requirement is that CURL command line tool is installed and functioning correctly. To check whether CURL is available on your system, execute following command in your console:

```
curl -h

```

If you see instructions on how to use CURL then your system has the CURL binary installed and you can use the `async` handler.

> Keep in mind that Laravel allows you to specify different configuration values in different environments. You could, for example, use the async handler in production and the sync handler in development.

##### Laravel queue handler

[](#laravel-queue-handler)

Although we generally recommend using the async handler, making use of queues is another another option. Bear in mind that by the default Laravel queue is `sync`, so you will still need to configure your queues properly using something like iron.io or Amazon SQS. See  for more information.

### Configuration

[](#configuration)

```
return [

    /**
     * Input key
     */
    'token' => 'your-input-token-from-understand-io',

    /**
     * Specifies whether logger should throw an exception of issues detected
     */
    'silent' => true,

    /**
     * Specify which handler to use - sync, queue or async.
     *
     * Note that the async handler will only work in systems where
     * the CURL command line tool is installed
     */
    'handler' => 'sync',

    'log_types' => [
        'eloquent_log' => [
            'enabled' => false,
            'meta' => [
                'session_id' => 'UnderstandFieldProvider::getSessionId',
                'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
                'user_id' => 'UnderstandFieldProvider::getUserId',
                'env' => 'UnderstandFieldProvider::getEnvironment',
                'client_ip' => 'UnderstandFieldProvider::getClientIp',
            ]
        ],
        'laravel_log' => [
            'enabled' => true,
            'meta' => [
                'session_id' => 'UnderstandFieldProvider::getSessionId',
                'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
                'user_id' => 'UnderstandFieldProvider::getUserId',
                'env' => 'UnderstandFieldProvider::getEnvironment',
            ]
        ],
        'exception_log' => [
            'enabled' => true,
            'meta' => [
                'session_id' => 'UnderstandFieldProvider::getSessionId',
                'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
                'user_id' => 'UnderstandFieldProvider::getUserId',
                'env' => 'UnderstandFieldProvider::getEnvironment',
                'url' => 'UnderstandFieldProvider::getUrl',
                'method' => 'UnderstandFieldProvider::getRequestMethod',
                'client_ip' => 'UnderstandFieldProvider::getClientIp',
                'user_agent' => 'UnderstandFieldProvider::getClientUserAgent'
            ]
        ]
    ]

];
```

### Requirements

[](#requirements)

##### UTF-8

[](#utf-8)

This package uses the json\_encode function, which only supports UTF-8 data, and you should therefore ensure that all of your data is correctly encoded. In the event that your log data contains non UTF-8 strings, then the json\_encode function will not be able to serialize the data.

### License

[](#license)

The Laravel Understand.io service provider is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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 ~146 days

Recently: every ~452 days

Total

15

Last Release

2256d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d07aaeb33d6be84336efa41cd2f95339d2971a1da19a77b3d57130607481ef55?d=identicon)[understand](/maintainers/understand)

---

Top Contributors

[![aivis](https://avatars.githubusercontent.com/u/935577?v=4)](https://github.com/aivis "aivis (48 commits)")[![rikh42](https://avatars.githubusercontent.com/u/715133?v=4)](https://github.com/rikh42 "rikh42 (1 commits)")

---

Tags

laravellogsunderstandundertstand.io

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/understand-understand-laravel4/health.svg)

```
[![Health](https://phpackages.com/badges/understand-understand-laravel4/health.svg)](https://phpackages.com/packages/understand-understand-laravel4)
```

###  Alternatives

[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91245.3M585](/packages/laravel-pail)[understand/understand-laravel5

Laravel 5, 6, 7, 8, 9, 10, 11 and 12 service provider for Understand.io

24586.8k](/packages/understand-understand-laravel5)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151376.5k4](/packages/jackiedo-log-reader)[understand/understand-laravel

Laravel 5, 6, 7, 8, 9, 10, 11 and 12 service provider for Understand.io

24106.2k](/packages/understand-understand-laravel)[kssadi/log-tracker

A powerful, intuitive, and efficient log viewer for Laravel applications.

264.8k](/packages/kssadi-log-tracker)

PHPackages © 2026

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