Download the PHP package merkeleon/laravel-log without Composer

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

Laravel log

Laravel module for logs generating

Installation

First, require the package using Composer:

composer require merkeleon/laravel-log

  1. Add new class Log that should extend Merkeleon\Log\Model\Log

  2. Custom your log class.

    • Add protected static attribute $table - the name of table or elastic search index
    • Add custom parameters $customAttributes. By default only parameters Log::$attributes will be save. The keys of Log::$customAttributes are parameters identificators. The values of Log::$customAttributes are casts. Following casts are supported:
      • int
      • float
      • string
      • bool
      • array
    • You can add validation rules.
    • If you want to duplicate your logs to files you should override function toLogFileArray
  3. Add the merkeleon_log.php config php artisan vendor:publish --provider="Merkeleon\Log\Providers\MerkeleonLogProvider"

    • Point your log class
    • Point the driver (mysql or elastic)
    • If you want to duplicate your logs to files you should point the path to log file.
  4. If you want save your logs to buffer and then bulk write all logs from buffer to storage
    • Add buffer directory path to the merkeleon_log.php config. Buffer directory should be writable
    • You should empty your buffer by calling command php artisan merkeleon:log:bulk-insert-to-storage {logName}

Example:

<?php

namespace App\Models;

use Merkeleon\Log\Model\Log;

class AuditLog extends Log
{
    protected static $table = 'audit_logs';

    protected static $customAttributes = [
        'user_id' => 'int',
        'user_id_related' => 'int',
        'data' => 'array',
    ];

    protected static $rules = [
        'event_type'      => 'required',
        'ip'              => 'required',
        'user_agent'      => 'required',
        'user_id'         => 'integer',
        'user_id_related' => 'integer',
    ];

    public function toLogFileArray()
    {
        return [
            "created_at"         => $this->created_at->format('Y-m-d H:i:s'),
            "ip"                 => $this->ip,
            "event_type"         => $this->event_type,
            "user_id"            => $this->user_id,
            "user_id_related"    => empty($this->user_id_related) ? '-' : $this->user_id_related,
            "user_agent"         => '"' . $this->user_agent . '"',
            "data"               => json_encode($this->data)
        ];
    }

}

    <?php

    return [
        'audit_log' => [
            'class' => \App\Models\AuditLog::class,
            'driver' => 'elastic',
            'log_file' => '/var/www/logs/audit_log.log'
        ],
    ];

Usage

Examples

$auditLogRepository = LogRepository::make('audit_log');

$auditLogRepository->write([
    'user_id'         => 1,
    'event_type'      => 'user_banned',
    'user_id_related' => 2,
    'data'            => [
        'user'         => [
            'id'   => '1',
            'name' => 'Admin User',
        ],
        'user_related' => [
            'id'   => '2',
            'name' => 'Test user'
        ]
    ]
]);

$auditLogRepository->where('user_id', 1)->orderBy('event_type', 'asc')->paginate(10);

$auditLogRepository->where('user_id', 1)->get();

Examples

    $auditLogRepository = LogRepository::make('audit_log');

    $auditLogRepository->write([
        'user_id'         => 1,
        'event_type'      => 'user_banned',
        'user_id_related' => 2,
        'data'            => [
            'user'         => [
                'id'   => '1',
                'name' => 'Admin User',
            ],
            'user_related' => [
                'id'   => '2',
                'name' => 'Test user'
            ]
        ]
    ], true);

    $auditLogRepository->write([
        'user_id'         => 1,
        'event_type'      => 'user_login',
        'data'            => [
            'user'         => [
                'id'   => '1',
                'name' => 'Admin User',
            ]
        ]
    ], true);

    // call command `php artisan merkeleon:log:bulk-insert-to-storage audit_log`

    $auditLogRepository->where('user_id', 1)->orderBy('event_type', 'asc')->paginate(10);

    $auditLogRepository->where('user_id', 1)->get();

All versions of laravel-log with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
laravel/framework Version >=5.0
ramsey/uuid Version ^4.1
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 merkeleon/laravel-log contains the following files

Loading the files please wait ....