PHPackages                             genealabs/laravel-caffeine - 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. genealabs/laravel-caffeine

ActiveLibrary

genealabs/laravel-caffeine
==========================

Keeping Your Laravel Forms Awake

13.0.0(2mo ago)9382.1M↑23.8%8610MITPHPCI passing

Since Aug 14Pushed 2mo ago23 watchersCompare

[ Source](https://github.com/mikebronner/laravel-caffeine)[ Packagist](https://packagist.org/packages/genealabs/laravel-caffeine)[ GitHub Sponsors](https://github.com/mikebronner)[ RSS](/packages/genealabs-laravel-caffeine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (79)Used By (10)

☕ Caffeine for Laravel
======================

[](#-caffeine-for-laravel)

[![GitHub Actions](https://camo.githubusercontent.com/156b291c9a9302ba674ac5fe2e3953ef68bf2f355ef49f0791f1d864765836d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f47656e65614c6162732f6c61726176656c2d6361666665696e652f6c61726176656c2e796d6c3f6272616e63683d6d6173746572)](https://github.com/GeneaLabs/laravel-caffeine/actions)[![Scrutinizer](https://camo.githubusercontent.com/18a71119de329057845c3d22aed358d396d656e58b19bf12763b9688a6bce923/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f47656e65614c6162732f6c61726176656c2d6361666665696e652e737667)](https://scrutinizer-ci.com/g/GeneaLabs/laravel-caffeine)[![GitHub (pre-)release](https://camo.githubusercontent.com/0444beaba25f33e1ec4ad949d33c0b4c887e33cd18effd9ebbffb923303fdb2c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f47656e65614c6162732f6c61726176656c2d6361666665696e652f616c6c2e737667)](https://github.com/GeneaLabs/laravel-caffeine)[![Packagist](https://camo.githubusercontent.com/e1623138170fe13d0c2250c69ec65755609d231e48998c719b9fa4837e58f551/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f47656e65614c6162732f6c61726176656c2d6361666665696e652e737667)](https://packagist.org/packages/genealabs/laravel-caffeine)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/GeneaLabs/laravel-caffeine/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/4bce8fa4bd5b5ab85554a624934225cf3cd3a18a7607dc56713ebbb118536020/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f67656e65616c6162732f6c61726176656c2d6361666665696e65)](https://packagist.org/packages/genealabs/laravel-caffeine)[![Laravel](https://camo.githubusercontent.com/751230d25052d87343977f7ce2d80c65e1b67ffc7c041857d28434849f583755/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3131253230253743253230313225323025374325323031332d464632443230)](https://laravel.com)[![GitHub Stars](https://camo.githubusercontent.com/069c47cd37b790c6fef1c1fc71fc1f0abc1a2f8ca45a4caf2f48d4f6bb94c473/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f47656e65614c6162732f6c61726176656c2d6361666665696e65)](https://github.com/GeneaLabs/laravel-caffeine/stargazers)

[![Caffeine for Laravel masthead image.](https://repository-images.githubusercontent.com/40729869/26446500-f1b2-11e9-9611-6a2e65688de2)](https://repository-images.githubusercontent.com/40729869/26446500-f1b2-11e9-9611-6a2e65688de2)

🗂️ Table of Contents
--------------------

[](#️-table-of-contents)

- [📖 Summary](#-summary)
- [📦 Installation](#-installation)
- [⚙️ Configuration](#%EF%B8%8F-configuration)
- [🚀 Usage](#-usage)
- [⚠️ Considerations](#%EF%B8%8F-considerations)
- [⬆️ Upgrading](#%EF%B8%8F-upgrading)
- [🤝 Contributing](#-contributing)
- [🔐 Security](#-security)

📖 Summary
---------

[](#-summary)

Prevent forms from timing out when submitting them after leaving them on-screen for a considerable amount of time. Laravel defaults session lifetime to 120 minutes, but that is configurable and could be different site-by-site.

☕ Caffeine works by sending a "drip" — a lightweight AJAX request at regular intervals — to keep the session alive while a form is open. It only activates on pages with a `_token` field or a `csrf-token` meta tag, so all other pages time-out as normal.

### 🔒 Why This Approach?

[](#-why-this-approach)

This package keeps the integrity of your site's security by avoiding the following:

- 🚫 Exposing the CSRF Token on an unsecured endpoint.
- 🚫 Eliminating CSRF Token validation on specific routes, or altogether.
- 🚫 Removing session-timeout on all pages.

### 📋 Requirements

[](#-requirements)

- PHP 8.2+
- Laravel 11, 12, or 13

📦 Installation
--------------

[](#-installation)

```
composer require genealabs/laravel-caffeine
```

✨ The service provider is auto-discovered. No additional setup is required.

⚙️ Configuration
----------------

[](#️-configuration)

***Only publish the config file if you need to customize it***:

```
php artisan caffeine:publish --config
```

This creates the following config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Drip Interval
    |--------------------------------------------------------------------------
    |
    | Here you may configure the interval with which Caffeine for Laravel
    | keeps the session alive. By default this is 5 minutes (expressed
    | in milliseconds). This needs to be shorter than your session
    | lifetime value configured set in "config/session.php".
    |
    | Default: 300000 (int)
    |
    */
    'drip-interval' => 300000,

    /*
    |--------------------------------------------------------------------------
    | Domain
    |--------------------------------------------------------------------------
    |
    | You may optionally configure a separate domain that you are running
    | Caffeine for Laravel on. This may be of interest if you have a
    | monitoring service that queries other apps. Setting this to
    | null will use the domain of the current application.
    |
    | Default: null (null|string)
    |
    */
    'domain' => null,

    /*
    |--------------------------------------------------------------------------
    | Drip Endpoint URL
    |--------------------------------------------------------------------------
    |
    | Sometimes you may wish to white-label your app and not expose the AJAX
    | request URLs as belonging to this package. To achieve that you can
    | rename the URL used for dripping caffeine into your application.
    |
    | Default: 'genealabs/laravel-caffeine/drip' (string)
    |
    */
    'route' => 'genealabs/laravel-caffeine/drip',

    /*
    |--------------------------------------------------------------------------
    | Checking for Lapsed Drips
    |--------------------------------------------------------------------------
    |
    | If the browser tab is suspended due to inactivity or the device is put to
    | sleep, it will still cause an error when trying to submit the form. To
    | avoid this, we force-reload the form 2 minutes prior to session
    | time-out or later. Setting this setting to 0 will disable this
    | check if you don't want to use it.
    |
    | Default: 2000 (int)
    |
    */
    'outdated-drip-check-interval' => 2000,

    /*
    |--------------------------------------------------------------------------
    | Use Route Middleware
    |--------------------------------------------------------------------------
    |
    | Drips are enabled via route middleware instead of global middleware.
    |
    | Default: false (bool)
    |
    */
    'use-route-middleware' => false,

];
```

🚀 Usage
-------

[](#-usage)

That's it! It will apply itself automatically where it finds a form with a `_token` field, or a meta tag named "csrf-token", while pages are open in browsers. 🎉

### 🚫 Prevent Caffeination

[](#-prevent-caffeination)

There are two methods to prevent Caffeine from keeping the session alive:

#### 🏷️ Meta Tag Method

[](#️-meta-tag-method)

Add the following meta tag to any page you want to exclude:

```

```

#### 🛣️ Route Middleware Method

[](#️-route-middleware-method)

Publish the config file and set `use-route-middleware` to `true`. This disables the default global middleware mode. Then selectively enable Caffeine on specific routes or route groups:

```
Route::any('test', 'TestController@test')->middleware('caffeinated');

Route::middleware(['caffeinated'])->group(function () {
    Route::any('test', 'TestController@test');
});
```

> **📝 Note:** This will only have effect if the page includes a form. If not, the page will not caffeinate your application anyway.

⚠️ Considerations
-----------------

[](#️-considerations)

### 🔌 Livewire / Inertia / SPA

[](#-livewire--inertia--spa)

This package works by injecting JavaScript that pings a keep-alive endpoint. It is designed for traditional Blade forms. If you are using **Livewire** or **Inertia**, their built-in request cycles typically keep the session alive already, so this package is generally unnecessary in those contexts.

### 🚧 Incompatible Packages

[](#-incompatible-packages)

- [Voyager](https://github.com/the-control-group/voyager) has been reported as being incompatible. To work around this, configure Caffeine to use route-based middleware on all non-Voyager routes.

### 🛤️ Routes

[](#️-routes)

This package registers routes under `genealabs/laravel-caffeine`.

⬆️ Upgrading
------------

[](#️-upgrading)

### 0.6.0

[](#060)

This update changed the config file setting names. Delete the published config file `config/genealabs-laravel-caffeine.php` if it exists, and re-publish using the command in the [Configuration](#%EF%B8%8F-configuration) section.

For all other version changes, see the [Releases](https://github.com/GeneaLabs/laravel-caffeine/releases) page on GitHub.

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! 🎉 Please review the [Contribution Guidelines](https://github.com/GeneaLabs/laravel-caffeine/blob/master/CONTRIBUTING.md)and observe the [Code of Conduct](https://github.com/GeneaLabs/laravel-caffeine/blob/master/CODE_OF_CONDUCT.md)before submitting a pull request.

### 🧪 Quality Checklist

[](#-quality-checklist)

- ✅ Achieve as close to 100% code coverage as possible using unit tests.
- ✅ Be fully PSR-1, PSR-4, and PSR-12 compliant.
- ✅ Provide an up-to-date [CHANGELOG.md](CHANGELOG.md) adhering to [Keep a Changelog](https://keepachangelog.com).
- ✅ Have no PHPMD or PHPCS warnings throughout all code.

🔐 Security
----------

[](#-security)

If you discover a security vulnerability, please report it via [GitHub Security Advisories](https://github.com/GeneaLabs/laravel-caffeine/security/advisories)rather than opening a public issue.

---

Built with ❤️ for the Laravel community using lots of ☕ by [Mike Bronner](https://github.com/mikebronner).

This is an MIT-licensed open-source project. Its continued development is made possible by the community. If you find it useful, please consider [💖 becoming a sponsor](https://github.com/sponsors/mikebronner)and [⭐ starring it on GitHub](https://github.com/GeneaLabs/laravel-caffeine).

###  Health Score

70

—

ExcellentBetter than 100% of packages

Maintenance85

Actively maintained with recent releases

Popularity64

Solid adoption and visibility

Community40

Growing community involvement

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~57 days

Recently: every ~88 days

Total

68

Last Release

78d ago

Major Versions

8.0.0 → 9.0.02022-02-09

9.0.4 → 10.0.02023-03-10

10.0.2 → 11.0.02024-03-03

11.0.0 → 12.0.02025-03-12

12.0.3 → 13.0.02026-03-01

PHP version history (3 changes)0.1.0PHP &gt;=5.5.0

0.4.0PHP &gt;=7.0.0

0.6.8PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/4374bfc5d8583aa8c25c5080f1fcfaf09027822f47724ba6b64abc564945c80a?d=identicon)[mikebronner](/maintainers/mikebronner)

---

Top Contributors

[![mikebronner](https://avatars.githubusercontent.com/u/1791050?v=4)](https://github.com/mikebronner "mikebronner (244 commits)")[![ItaloBC](https://avatars.githubusercontent.com/u/26698421?v=4)](https://github.com/ItaloBC "ItaloBC (11 commits)")[![TheoKouzelis](https://avatars.githubusercontent.com/u/4980126?v=4)](https://github.com/TheoKouzelis "TheoKouzelis (3 commits)")[![alexey-m-ukolov](https://avatars.githubusercontent.com/u/1778239?v=4)](https://github.com/alexey-m-ukolov "alexey-m-ukolov (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![shatterproof](https://avatars.githubusercontent.com/u/4100078?v=4)](https://github.com/shatterproof "shatterproof (2 commits)")[![RenoLooijmans](https://avatars.githubusercontent.com/u/73367951?v=4)](https://github.com/RenoLooijmans "RenoLooijmans (2 commits)")[![DariusIII](https://avatars.githubusercontent.com/u/3399658?v=4)](https://github.com/DariusIII "DariusIII (2 commits)")[![michellaurent](https://avatars.githubusercontent.com/u/1630290?v=4)](https://github.com/michellaurent "michellaurent (2 commits)")[![hashimaziz1](https://avatars.githubusercontent.com/u/16962031?v=4)](https://github.com/hashimaziz1 "hashimaziz1 (1 commits)")[![inxilpro](https://avatars.githubusercontent.com/u/21592?v=4)](https://github.com/inxilpro "inxilpro (1 commits)")[![ipalaus](https://avatars.githubusercontent.com/u/248183?v=4)](https://github.com/ipalaus "ipalaus (1 commits)")[![jbrooksuk](https://avatars.githubusercontent.com/u/246103?v=4)](https://github.com/jbrooksuk "jbrooksuk (1 commits)")[![Konafets](https://avatars.githubusercontent.com/u/363363?v=4)](https://github.com/Konafets "Konafets (1 commits)")[![KristofMorva](https://avatars.githubusercontent.com/u/5695015?v=4)](https://github.com/KristofMorva "KristofMorva (1 commits)")[![mauritskorse](https://avatars.githubusercontent.com/u/3665483?v=4)](https://github.com/mauritskorse "mauritskorse (1 commits)")[![MultiSuperFreek](https://avatars.githubusercontent.com/u/31889292?v=4)](https://github.com/MultiSuperFreek "MultiSuperFreek (1 commits)")[![percymamedy](https://avatars.githubusercontent.com/u/11259669?v=4)](https://github.com/percymamedy "percymamedy (1 commits)")[![rjsworking](https://avatars.githubusercontent.com/u/9252353?v=4)](https://github.com/rjsworking "rjsworking (1 commits)")[![sjbronner](https://avatars.githubusercontent.com/u/3920512?v=4)](https://github.com/sjbronner "sjbronner (1 commits)")

---

Tags

laravelmiddlewarepackage

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/genealabs-laravel-caffeine/health.svg)

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

###  Alternatives

[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.2k124.3M624](/packages/barryvdh-laravel-debugbar)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)[label84/laravel-mailviewer

View mails sent by Laravel in the browser

1429.5k](/packages/label84-laravel-mailviewer)

PHPackages © 2026

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