PHPackages                             samasend/laravel-key-rotate - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. samasend/laravel-key-rotate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

samasend/laravel-key-rotate
===========================

Rotate your Laravel application key with ease

v1.0.0(2y ago)81.3k1[1 PRs](https://github.com/SamAsEnd/laravel-key-rotate/pulls)MITPHPPHP ^8.2

Since Mar 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/SamAsEnd/laravel-key-rotate)[ Packagist](https://packagist.org/packages/samasend/laravel-key-rotate)[ RSS](/packages/samasend-laravel-key-rotate/feed)WikiDiscussions master Synced 1mo ago

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

Laravel [Key Rotate](https://laravel.com/docs/11.x/encryption#gracefully-rotating-encryption-keys) [![From Ethiopia](https://camo.githubusercontent.com/66c6a32db01e06aacac1a2de912c9a81c4cc6e9d2050923d20db79718391eab1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46726f6d2d457468696f7069615f2546302539462538372541412546302539462538372542392d627269676874677265656e3f7374796c653d706c6173746963)](https://camo.githubusercontent.com/66c6a32db01e06aacac1a2de912c9a81c4cc6e9d2050923d20db79718391eab1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46726f6d2d457468696f7069615f2546302539462538372541412546302539462538372542392d627269676874677265656e3f7374796c653d706c6173746963)
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#laravel-key-rotate-)

[![Github Actions](https://github.com/SamAsEnd/laravel-key-rotate/actions/workflows/tests.yml/badge.svg)](https://github.com/SamAsEnd/laravel-key-rotate/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/31e8b31ac2b49a40332e02eecddc6a96489dde61607c0a6aa5083ec1d838b0b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616d6173656e642f6c61726176656c2d6b65792d726f746174653f7374796c653d706c6173746963)](https://packagist.org/packages/samasend/laravel-key-rotate)[![Latest Stable Version](https://camo.githubusercontent.com/e4f5ee8f08568411b27bbf88f22f375395d91fe75d0119e2280dbaf68fad507c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616d6173656e642f6c61726176656c2d6b65792d726f746174653f7374796c653d706c6173746963)](https://packagist.org/packages/samasend/laravel-key-rotate)[![License](https://camo.githubusercontent.com/1db78783f24e142b23711d12f6b2dbf0bf8733c80a7c2dbacc8c95a03ace4850/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73616d6173656e642f6c61726176656c2d6b65792d726f746174653f7374796c653d706c6173746963)](https://packagist.org/packages/samasend/laravel-key-rotate)

Laravel Key Rotate is a package that extends Laravel's built-in `key:generate` command, providing a simple and efficient way to rotate your Laravel application's key.

This is particularly useful for maintaining the security and integrity of your application by ensuring that the encryption key is regularly updated.

Prerequisites
-------------

[](#prerequisites)

- **PHP** &gt;= 8.2
- **Laravel** &gt;= 11.x

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

[](#installation)

You can install the package via composer:

```
composer require samasend/laravel-key-rotate
```

Usage
-----

[](#usage)

To rotate your application key, simply run the following artisan command:

```
php artisan key:rotate
```

This command will generate a new application key and update your `.env` file. The previous key will be stored in the `APP_PREVIOUS_KEYS` environment variable, allowing for graceful key rotation.

How It Works
------------

[](#how-it-works)

The `key:rotate` command extends Laravel's built-in `key:generate` command. When run, it generates a new application key as usual. However, instead of simply replacing the old key, it stores the old key in the `APP_PREVIOUS_KEYS` environment variable. This allows for a smooth transition to the new key, as the old key is still available for decrypting any data that was encrypted with it.

> Ideally, this feature should have been implemented in Laravel core, [but it's not](https://github.com/laravel/framework/pull/50322). So, this package is here to help you.

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Total

2

Last Release

779d ago

Major Versions

v0.1.0 → v1.0.02024-03-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fd28cb32a4cca3aaf21187959977a78066f4bc4c8b110c959efcf117e6dc4c4?d=identicon)[SamAsEnd](/maintainers/SamAsEnd)

---

Top Contributors

[![SamAsEnd](https://avatars.githubusercontent.com/u/9657132?v=4)](https://github.com/SamAsEnd "SamAsEnd (6 commits)")

---

Tags

laravelkeyrotate

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/samasend-laravel-key-rotate/health.svg)

```
[![Health](https://phpackages.com/badges/samasend-laravel-key-rotate/health.svg)](https://phpackages.com/packages/samasend-laravel-key-rotate)
```

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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