PHPackages                             keyshang/laravel-authentication-log - 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. keyshang/laravel-authentication-log

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

keyshang/laravel-authentication-log
===================================

Laravel Authentication Log provides authentication logger and notification for Laravel.

v2.0.0(4y ago)014MITPHPPHP &gt;=7.2

Since Sep 18Pushed 2y agoCompare

[ Source](https://github.com/KeyShang/laravel-authentication-log)[ Packagist](https://packagist.org/packages/keyshang/laravel-authentication-log)[ RSS](/packages/keyshang-laravel-authentication-log/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (11)Used By (0)

Laravel Authentication Log
==========================

[](#laravel-authentication-log)

[![Build Status](https://camo.githubusercontent.com/1f7c0cc1b674c6422b6e373ddfa4f2dc72f729c28f9b8e7eac164076b8025910/68747470733a2f2f7472617669732d63692e636f6d2f4b65795368616e672f6c61726176656c2d61757468656e7469636174696f6e2d6c6f672e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/KeyShang/laravel-authentication-log)[![StyleCI](https://camo.githubusercontent.com/e9d0bf86352a15e4199e27b5d9981a844be1dfdc70cd8296e4cfddefb9ab68d1/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3336393735323634382f736869656c643f7374796c653d666c6174266272616e63683d6d6173746572)](https://github.styleci.io/repos/369752648)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/61ecac70a5daadefed2fee2970b2132a0fbb474bc3d091040f930d23174ca71d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b65795368616e672f6c61726176656c2d61757468656e7469636174696f6e2d6c6f672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KeyShang/laravel-authentication-log/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/bf9cbcc68255dd59708430414467476225864d12bccf45508bfc8abe97136825/68747470733a2f2f706f7365722e707567782e6f72672f6b65797368616e672f6c61726176656c2d61757468656e7469636174696f6e2d6c6f672f646f776e6c6f616473)](//packagist.org/packages/keyshang/laravel-authentication-log)[![GitHub license](https://camo.githubusercontent.com/f48f8d6cf609f5b181b9c3218a85175fe8a5809c7ea400347f39697a5d55065d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c6174)](https://raw.githubusercontent.com/KeyShang/laravel-authentication-log/master/LICENSE)

Function
--------

[](#function)

1. Record the user login and retrieve it
2. Notification via email when user login from a new device
3. The notification email can be translated by set locale. And already had English and Chinese translation.

Changelog
---------

[](#changelog)

### 2.0.0

[](#200)

Inspired by [yadahan/laravel-authentication-log](https://github.com/yadahan/laravel-authentication-log).

To make package simple and clean, remove unnecessary record logout function, Slack notification, NexmoMessage notification.

Add translatable email function, and add Chinese translation. Translation of more languages is welcome to push.

Add some other code improvements.

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

[](#installation)

> Require: Laravel 8.x, and PHP 7.2+.

1. Use Composer to install:

    composer require keyshang/laravel-authentication-log
2. Migrate your database. The Laravel Authentication Log migration will create the table your application needs to store authentication logs:

    php artisan migrate
3. Add the `AuthenticationLogable` and `Notifiable` traits to your authenticatable model (by default, `App\User` model). These traits provides various methods to allow you to get common authentication log data, such as last login time, last login IP address, and set the channels to notify the user when login from a new device:

```
use Illuminate\Notifications\Notifiable;
use KeyShang\AuthenticationLog\AuthenticationLogable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, AuthenticationLogable;
}
```

Override default config
-----------------------

[](#override-default-config)

Run the command below, and change the generated file in `config/authentication-log.php`.

```
php artisan vendor:publish --tag=authentication-log-config

```

### Notify login from a new device

[](#notify-login-from-a-new-device)

By default email notification is enable.

You can disable email notification by set the `notify` option in your `config/authentication-log.php` configuration file to `false`:

```
'notify' => env('AUTHENTICATION_LOG_NOTIFY', false),

```

### Clear old logs

[](#clear-old-logs)

You may clear the old authentication log records using the `authentication-log:clear` Artisan command:

```
php artisan authentication-log:clear

```

Records that is older than the number of days specified in the `older` option in your `config/authentication-log.php` will be deleted:

```
'older' => 365,

```

Override default views
----------------------

[](#override-default-views)

```
php artisan vendor:publish --tag=authentication-log-views

```

Override default translations
-----------------------------

[](#override-default-translations)

```
php artisan vendor:publish --tag=authentication-log-translations

```

Basic Usage
-----------

[](#basic-usage)

Get all authentication logs for the user:

```
User::find(1)->authentications;
```

Get the user last login info:

```
User::find(1)->lastLoginAt();

User::find(1)->lastLoginIp();
```

Get the user previous login time &amp; ip address (ignoring the current login):

```
auth()->user()->previousLoginAt();

auth()->user()->previousLoginIp();
```

Previewing Mail Notifications
-----------------------------

[](#previewing-mail-notifications)

In routes file, add following code to preview your Mail template.

```
Route::get('/notification', function () {
    $log = \KeyShang\AuthenticationLog\AuthenticationLog::first();
    $user = $log->authenticatable;
    return (new \KeyShang\AuthenticationLog\Notifications\NewDevice($log))
        ->toMail($user);
});
```

Contributing
------------

[](#contributing)

Thank you for considering contributing to the Laravel Authentication Log.

License
-------

[](#license)

Laravel Authentication Log is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 57.6% 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 ~154 days

Recently: every ~49 days

Total

10

Last Release

1768d ago

Major Versions

v1.4.2-p1 → v2.0.02021-07-07

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.4.2-p1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/030511f9efee3d2f7a594bc35ea8944f5341cf923b76e32962e66927f3b34d2c?d=identicon)[Key Shang](/maintainers/Key%20Shang)

---

Top Contributors

[![fireufo](https://avatars.githubusercontent.com/u/19263091?v=4)](https://github.com/fireufo "fireufo (34 commits)")[![yakidahan](https://avatars.githubusercontent.com/u/7757560?v=4)](https://github.com/yakidahan "yakidahan (21 commits)")[![bhavingajjar](https://avatars.githubusercontent.com/u/11258397?v=4)](https://github.com/bhavingajjar "bhavingajjar (1 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (1 commits)")[![PaulKenya](https://avatars.githubusercontent.com/u/27075431?v=4)](https://github.com/PaulKenya "PaulKenya (1 commits)")[![TechTailor](https://avatars.githubusercontent.com/u/14147474?v=4)](https://github.com/TechTailor "TechTailor (1 commits)")

---

Tags

loglaravelAuthenticationnotification

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/keyshang-laravel-authentication-log/health.svg)

```
[![Health](https://phpackages.com/badges/keyshang-laravel-authentication-log/health.svg)](https://phpackages.com/packages/keyshang-laravel-authentication-log)
```

###  Alternatives

[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[saasscaleup/laravel-log-alarm

Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email

27025.0k](/packages/saasscaleup-laravel-log-alarm)[hosmelq/laravel-logsnag

Integrate the power of LogSnag's real-time event tracking into your Laravel application.

237.9k](/packages/hosmelq-laravel-logsnag)

PHPackages © 2026

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