PHPackages                             protechstudio/oplogger - 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. protechstudio/oplogger

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

protechstudio/oplogger
======================

It offers a convenient way to create a user operation log for any Laravel 5 application. Supports parameters and writes log to database by default but can also be linked to different repositories.

1.3.2(10y ago)3291MITPHPPHP &gt;=5.5.9

Since Feb 10Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (8)Used By (0)

Oplogger
========

[](#oplogger)

It offers a convenient and fast way to create a user operation log for any Laravel 5 application. It supports parameters and writes log to database by default but can also be used with a custom repository.

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

[](#installation)

Require this package with composer using the following command:

```
composer require protechstudio/oplogger
```

After updating composer, add the service provider to the `providers` array in `config/app.php`

```
Protechstudio\Oplogger\OploggerProvider::class,
```

You may also add the Facade in the `aliases` array in `config/app.php`

```
'Oplogger' => Protechstudio\Oplogger\Facades\Oplogger::class,
```

Finally publish the configuration and migration files using the artisan command

```
php artisan vendor:publish --provider="Protechstudio\Oplogger\OploggerProvider"
```

You may also publish **only** the configuration file or the migration using the associated `config` and `migrations` tags

```
php artisan vendor:publish --provider="Protechstudio\Oplogger\OploggerProvider" --tag="config"
```

```
php artisan vendor:publish --provider="Protechstudio\Oplogger\OploggerProvider" --tag="migrations"
```

Run the migration ( *only needed if you intend to use the internal repository* )

```
php artisan migrate
```

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

[](#configuration)

Open the published configuration file at `config/oplogger.php`:

```
return [

    'types' => [
        'test' => 'Basic operation for testing purposes.'
    ],

    'repository' => Protechstudio\Oplogger\Repositories\LogRepository::class
];
```

Then populate the `types` array with all operation types with their specific message. If you intend to use a custom repository you must edit the `repository` element.

### Using a custom repository

[](#using-a-custom-repository)

The custom repository must implement the `LogRepositoryContract` as in the example below:

```
...
use Protechstudio\Oplogger\Repositories\LogRepositoryContract;

class CustomRepository implements LogRepositoryContract
{
    //your custom repository implementation
}
```

Usage
-----

[](#usage)

You may use the Oplogger service in two ways:

### Using the dependency or method injection

[](#using-the-dependency-or-method-injection)

```
...
use Protechstudio\Oplogger\Oplogger;

class FooController extends Controller
{
    private $oplogger;

    public function __construct(Oplogger $oplogger)
    {
        $this->oplogger = $oplogger;
    }

    public function bar()
    {
        $this->oplogger->write('test');
    }
}
```

### Using the Facade

[](#using-the-facade)

```
...
use Oplogger;

public function bar()
{
    Oplogger::write('test');
}
```

### Adding parameters to the operation string

[](#adding-parameters-to-the-operation-string)

The `write` method uses the `vsprintf` function internally so you may easily add any parameter you need to the type operation string in the `config/oplogger.php`

```
'types' => [
        'test' => 'Basic operation for testing purposes.',
        'myoperation' => 'Has made %d operations using %s',
    ],
```

Then you can pass an array of parameters as the second argument of the `write` method

```
Oplogger::write('myoperation',[4,'parameters']);

// Result will be: 'Has made 4 operations using parameters'
```

For advance use of parameters please check the [vsprintf](http://php.net/manual/en/function.vsprintf.php) documentation.

### Operation associated user

[](#operation-associated-user)

`Oplogger` automatically retrieves the logged in user using the Laravel `Auth` system. If you prefer you may also force to log the operation with a specific user passing the user id as the third argument

```
$userid=5;
Oplogger::write('test',[],$userid);
```

The internal repository
-----------------------

[](#the-internal-repository)

If you are using the internal repository, running the published migration will create a `logs` table with `user_id`, `operation` and laravel timestamp fields. **Please note that if you are not using the laravel default users table for users you should edit the migration accordingly or an exception will be thrown due to the user\_id foreign key constraint.**

You may access the underlying `Log` model adding `use Protechstudio\Oplogger\Models\Log;` to the use statements.

Exceptions
----------

[](#exceptions)

### Typing a wrong operation type key

[](#typing-a-wrong-operation-type-key)

If the operation key you type in the `write` method is not present in your configuration `types` array an `OploggerKeyNotFoundException` exception will be thrown.

### Not providing a user for the operation

[](#not-providing-a-user-for-the-operation)

If you don't provide a specific user for the operation and the user is not logged in an `OploggerUserNotLoggedException` exception will be thrown.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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 ~9 days

Total

7

Last Release

3739d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/08a162506d81945243da1aecbdc20ca367564374a5019135628201616e8f4c7c?d=identicon)[Silentscripter](/maintainers/Silentscripter)

---

Top Contributors

[![Silentscripter](https://avatars.githubusercontent.com/u/11164238?v=4)](https://github.com/Silentscripter "Silentscripter (8 commits)")

### Embed Badge

![Health badge](/badges/protechstudio-oplogger/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.0k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1941.5M265](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2328.5M323](/packages/open-telemetry-sdk)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8676.7k](/packages/illuminated-console-logger)

PHPackages © 2026

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