PHPackages                             diontech/laravel-vault - 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. [Security](/categories/security)
4. /
5. diontech/laravel-vault

ActiveLibrary[Security](/categories/security)

diontech/laravel-vault
======================

Building vaults and decrypted/encryped secrets. Using specfic keys per vault (or per secret if you want to) is implemented. Vaults can be a standalone or related to your app`s models.

v1.2.1(4y ago)11928↓34.4%2[2 PRs](https://github.com/DionTech/laravel-vault/pulls)MITPHPPHP ^8.0.2

Since Jun 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/DionTech/laravel-vault)[ Packagist](https://packagist.org/packages/diontech/laravel-vault)[ RSS](/packages/diontech-laravel-vault/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (4)Versions (13)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/cb286414bb8c2fc15608209e7be8a59791a4aac4aa50ed6ac547eee5571d395d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696f6e746563682f6c61726176656c2d7661756c743f6c6162656c3d76657273696f6e)](https://packagist.org/packages/diontech/laravel-vault/)[![run-tests](https://github.com/DionTech/laravel-vault/actions/workflows/run_tests.yml/badge.svg)](https://github.com/DionTech/laravel-vault/actions/workflows/run_tests.yml)[![GitHub last commit](https://camo.githubusercontent.com/92306b9a973c8b8bb062999db2937902d89730e4d865b913f1dc9c9979a4e388/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f64696f6e746563682f6c61726176656c2d7661756c74)](https://camo.githubusercontent.com/92306b9a973c8b8bb062999db2937902d89730e4d865b913f1dc9c9979a4e388/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f64696f6e746563682f6c61726176656c2d7661756c74)[![GitHub issues](https://camo.githubusercontent.com/97503e467009302e1e677c3bd9dfda2aa6aeb08fffc841be9dfff87d87916c50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d7261772f64696f6e746563682f6c61726176656c2d7661756c74)](https://camo.githubusercontent.com/97503e467009302e1e677c3bd9dfda2aa6aeb08fffc841be9dfff87d87916c50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d7261772f64696f6e746563682f6c61726176656c2d7661756c74)[![Packagist Downloads](https://camo.githubusercontent.com/450086e2473f68e13819993ae5f85d8089f3bcc8abec58a885875e01b6a42ade/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f64696f6e746563682f6c61726176656c2d7661756c742e7376673f6c6162656c3d7061636b6167697374253230646f776e6c6f616473)](https://packagist.org/packages/diontech/laravel-vault)[![License](https://camo.githubusercontent.com/5e25f857ea70d6e61023befad1d4195a9196c47ce3e73e4ef77a0d8e2e2e98f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d6d69742d626c75652e737667)](https://github.com/DionTech/laravel-vault/blob/main/LICENSE)[![Twitter Follow](https://camo.githubusercontent.com/8310805f07f2c4695422721024551912ea1468bf375536177e800d99072204ea/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f64696f6e5f746563683f7374796c653d736f6369616c)](https://twitter.com/dion_tech)

about Vault
===========

[](#about-vault)

With Vault, you can create vaults as application standalones or related to a model in your app, for example every user can have personal vaults. Each vault can contain secrets. Instead of using the default decrypt/encrypt functions, Vault will protect secrets using the keys you will choose. For example, an user can define its 'magic secret password' and must provide it every time he wants to have access to a secret. The way you will handle this is dependant to your case.

Vault will handle the key length internally and make sure, the length is 16 or 32, dependant to the cipher you will use (AES-128-CBC = 16, AES-256-CBC = 32). So you can choose the secret key you will want to.

releases / laravel support
==========================

[](#releases--laravel-support)

- laravel 8: v1.1.x
- laravel 9: v1.2.x

installation
============

[](#installation)

```
composer require diontech/laravel-vault
```

```
php artisan migrate
```

usage
=====

[](#usage)

```
//creating a vault without a related model
$vault = \DionTech\Vault\Models\Vault::create([
    'name' => 'application vault'
]);

//use default APP_KEY, adding secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->add("facaded_secret", "AN_API_KEY");

//use default APP_KEY, overwrite secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->overwrite("facaded_secret", "AN_API_KEY_overwritten");

//use default APP_KEY, get secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->get("facaded_secret");

//use own key, adding secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->add("facaded_secret", "AN_API_KEY");

//use own key, overwrite secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->overwrite("facaded_secret", "AN_API_KEY_overwritten");

//use own key, get secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->get("facaded_secret");
```

```
//adding a vault using the polymorphic relation
//at your model, add morphMany relation, for example at User:

use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
    //...

    public function vaults()
    {
        return $this->morphMany(\DionTech\Vault\Models\Vault::class, 'vaultable');
    }
}

//now add a vault at an $user instance later
$user = User::first();

$user->vaults()->create([
    'name' => 'personal'
]);

//now you will have access to the methods like using a facade when you will use the related model based vaults(), starting with open()

$user->vaults()->first()->add("AN_API_KEY", "this-is-the-sensible-value");
$user->vaults()->first()->overwrite("AN_API_KEY", "this-is-the-sensible-value-overwritten");
$user->vaults()->first()->get("AN_API_KEY");
```

There are now a few new options more now of how to write the code:

```
Vault::open("a vault name")->add("facaded_secret", "simple value"); //will create the vault
```

or when want a relational based vault:

```
$user = User::first();
Vault::setContext($user)->open("personal")->add('bad_password_storing_itself', '12345678'); //will create a vault in relation to the user
```

So vaults are created or loaded (when already exists) when you only type a string.

changing the KeyService hash alogorithm
=======================================

[](#changing-the-keyservice-hash-alogorithm)

You can publish the config file - after that, you can change the algo at config/vault.php; default is set to sha512. Supported are listed at .

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~46 days

Recently: every ~78 days

Total

8

Last Release

1572d ago

Major Versions

v0.9.2 → v1.0.02021-06-17

PHP version history (2 changes)v0.9.0PHP ^7.4|^8.0

v1.2.0PHP ^8.0.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76866294?v=4)[Daniel Koch](/maintainers/DionTech)[@DionTech](https://github.com/DionTech)

---

Top Contributors

[![DionTech](https://avatars.githubusercontent.com/u/76866294?v=4)](https://github.com/DionTech "DionTech (45 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/diontech-laravel-vault/health.svg)

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

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

137236.2k8](/packages/statamic-rad-pack-runway)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3622.8k](/packages/duncanmcclean-statamic-cargo)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21327.3k4](/packages/ecotone-laravel)

PHPackages © 2026

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