PHP code example of nawasara / vault
1. Go to this page and download the library: Download nawasara/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/ */
nawasara / vault example snippets
// config/nawasara-vault.php
'groups' => [
'cloudflare' => [
'label' => 'Cloudflare',
'icon' => 'lucide-cloud',
'test' => \Nawasara\Cloudflare\Services\CloudflareClient::class.'@testConnection',
'fields' => [
'api_token' => ['label' => 'API Token', 'type' => 'password'],
'account_id' => ['label' => 'Account ID', 'type' => 'text'],
],
],
'whm' => [
'label' => 'WHM / cPanel',
'icon' => 'lucide-hard-drive',
'multi_instance' => true,
'test' => \Nawasara\Whm\Services\WhmClient::class.'@testConnection',
'fields' => [
'host' => ['label' => 'Host', 'type' => 'text'],
'username' => ['label' => 'Username', 'type' => 'text'],
'api_token' => ['label' => 'API Token', 'type' => 'password'],
'role' => ['label' => 'Role', 'type' => 'select', 'options' => [
'hosting' => 'Hosting', 'mail' => 'Mail', 'both' => 'Both',
]],
'ssh_key' => ['label' => 'SSH Key (PEM)', 'type' => 'textarea', 'optional' => true],
],
],
],
use Nawasara\Vault\Facades\Vault;
// Single instance
$token = Vault::get('cloudflare', 'api_token');
// Multi-instance
$host = Vault::get('whm', 'host', 'WHM-Ryder');
// Boolean checks
Vault::has('cloudflare', 'api_token');
Vault::isConfigured('cloudflare'); // every delete('cloudflare', 'api_token');
public function testConnection(?string $instance = null): array
{
return [
'success' => true,
'message' => 'Connected. Listed 12 items.',
];
}
bash
composer migrate
php artisan db:seed --class="Nawasara\Vault\Database\Seeders\PermissionSeeder" --force