1. Go to this page and download the library: Download secretstack/laravel-vault library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
config('database.connections.mysql.password'); // resolves the Vault value
env('STRIPE_SECRET'); // resolves the Vault value
use Vaultenv\Vault\Facades\Vault;
Vault::get('STRIPE_SECRET'); // string|null
Vault::get('FEATURE_FLAG', 'default'); // with a default
Vault::all(); // array<string, string>
Vault::refresh(); // reload in-process (dev / cache-warm; NOT a prod hot-reload)
public function __construct(private \Vaultenv\Vault\Secrets\SecretStore $secrets) {}
// $this->secrets->get('STRIPE_SECRET');
use Vaultenv\Vault\Exceptions\SecretProviderException;
try {
$value = Vault::get('STRIPE_SECRET');
} catch (SecretProviderException $e) {
// log/handle — the message never contains a secret value
}
namespace Vaultenv\Vault\Contracts;
interface SecretProvider
{
/**
* @return array<string, string>
* @throws \Vaultenv\Vault\Exceptions\SecretProviderException
*/
public function fetch(): array;
}
sh
set -e
php artisan vault:check --gate # halts a bad rollout; old pods keep serving
php artisan config:cache # freezes config WITH the injected Vault values
php artisan route:cache
php artisan view:cache
# start your server (php-fpm / octane / supervisord / …)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.