Laravel Vault Suite connects your Laravel applications to dedicated secrets backends such as HashiCorp Vault and OpenBao. It ships with an extensible driver system, an expressive facade, and artisan tooling so you can read, write, and manage secrets without copying values into .env
files.
📘 Documentation: https://omar-karray.github.io/laravel-vault-suite/
vault:unseal
, vault:enable-engine
, …) for the tasks operators and developers run every day.composer require deepdigs/laravel-vault-suite
Publish the configuration file to tailor drivers and bootstrap behaviour:
php artisan vendor:publish --tag="vault-suite-config"
Add the relevant environment variables in your .env
file (or server configuration):
VAULT_SUITE_DRIVER=vault
VAULT_ADDR=http://127.0.0.1:8200
VAULT_TOKEN=your-root-or-app-token
VAULT_ENGINE_MOUNT=secret
VAULT_ENGINE_VERSION=2
Read a secret as an array:
use Deepdigs\LaravelVaultSuite\Facades\LaravelVaultSuite;
$database = LaravelVaultSuite::fetch('apps/laravel/database');
Read a specific key from the secret payload:
$password = LaravelVaultSuite::fetch('apps/laravel/database', 'password');
Write or update a secret:
LaravelVaultSuite::put('apps/laravel/database', [
'username' => 'laravel',
'password' => 'new-password',
]);
List secret keys beneath a path:
$keys = LaravelVaultSuite::list('apps/laravel');
vault:unseal
– Submit key shards (from CLI or a file) and track progress until Vault is unsealed.
php artisan vault:unseal --file=storage/keys/unseal.txt --reset
vault:enable-engine
– Mount and configure secrets engines with typed options.
php artisan vault:enable-engine secret/apps --option=version=2 --local
See docs/commands.md for the full option reference.
composer update deepdigs/laravel-vault-suite
after changing this package’s composer.json
or autoloading configuration.composer test
Project docs are powered by MkDocs. Preview locally with:
pip install mkdocs mkdocs-material
mkdocs serve
The documentation source lives in docs/
and can be deployed to GitHub Pages via mkdocs gh-deploy --clean
.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
VAULT_ADDR
, VAULT_TOKEN
, and mount settings in .env
or your secret manager.php artisan vault:status
php artisan vault:enable-engine secret/apps --option=version=2
php artisan vault:read secret/apps/database --json
Write new values from PHP:
use Deepdigs\LaravelVaultSuite\LaravelVaultSuite;
app(LaravelVaultSuite::class)->put('secret/apps/database', [
'username' => 'laravel',
'password' => Str::random(32),
]);
vault:list
to confirm a rotation, then fetch credentials for tests).Until the bootstrapper ships, load secrets in a service provider or dedicated config loader:
use Deepdigs\LaravelVaultSuite\LaravelVaultSuite;
class VaultConfigServiceProvider extends ServiceProvider
{
public function boot(LaravelVaultSuite $vault): void
{
if (! app()->environment('production')) {
return;
}
$database = $vault->fetch('secret/apps/database');
config([
'database.connections.mysql.username' => $database['username'],
'database.connections.mysql.password' => $database['password'],
]);
}
}
ℹ️ When the bootstrapper lands, you will be able to map these keys directly inside
config/vault-suite.php
and hydrate them duringconfig:cache
.
php artisan vault:enable-engine database/credentials --type=kv --option=version=2
php artisan vault:read database/credentials/mysql-root --json # verify
Or programmatically via Laravel Vault Suite:
$vault->put('database/credentials/mysql-app', [
'username' => 'app',
'password' => Str::random(40),
]);
config:cache
.put
new password), then redeploy the application so it fetches the updated secret. Combine with Vault’s DB secrets engine if you want automated rotation.php artisan vault:status
during health checks.vault:unseal
with the key shards available to your SRE team or automation.config:cache
after updating configuration if you load secrets at boot.