Secrets Manager Installation
Before you begin
You'll need:
- A ByteHide account and project token
- PHP 7.4 or higher installed
- Composer package manager
Installation Options
Add the ByteHide Secrets SDK to your project using one of these methods:
Using Composer (Recommended)
Bash
composer require bytehide/secretscomposer require bytehide/secretsManual Installation
Download the source and include the autoloader:
PHP
require 'path/to/bytehide-secrets/vendor/autoload.php';require 'path/to/bytehide-secrets/vendor/autoload.php';Initialize the SDK
Once installed, you need to initialize the SDK with your project token.
Using Environment Variables (Recommended)
Set up environment variables and the SDK will auto-initialize:
PHP
<?php
require 'vendor/autoload.php';
use ByteHide\Secrets\SecretsManager;
// Environment variables:
// BYTEHIDE_SECRETS_TOKEN=f8118003-c24d-4f6f-9057-1a0d0b89ef55
// BYTEHIDE_SECRETS_ENVIRONMENT=production
// The SDK will read from environment variables automatically
$apiKey = SecretsManager::get('API_KEY');
echo "API Key: $apiKey\n";<?php
require 'vendor/autoload.php';
use ByteHide\Secrets\SecretsManager;
// Environment variables:
// BYTEHIDE_SECRETS_TOKEN=f8118003-c24d-4f6f-9057-1a0d0b89ef55
// BYTEHIDE_SECRETS_ENVIRONMENT=production
// The SDK will read from environment variables automatically
$apiKey = SecretsManager::get('API_KEY');
echo "API Key: $apiKey\n";Direct Initialization
For testing or development scenarios, you can initialize directly with a token:
PHP
<?php
use ByteHide\Secrets\SecretsManager;
// Not recommended for production - use environment variables instead
SecretsManager::unsecureInitialize('f8118003-c24d-4f6f-9057-1a0d0b89ef55', 'production');<?php
use ByteHide\Secrets\SecretsManager;
// Not recommended for production - use environment variables instead
SecretsManager::unsecureInitialize('f8118003-c24d-4f6f-9057-1a0d0b89ef55', 'production');Security Notice
Never hardcode your token in source code. For production environments, always use environment variables or a secure vault.
Environment Variables Setup
Development Environment
Bash
# Linux/macOS
export BYTEHIDE_SECRETS_TOKEN=your-token-here
export BYTEHIDE_SECRETS_ENVIRONMENT=development
# Windows (Command Prompt)
set BYTEHIDE_SECRETS_TOKEN=your-token-here
set BYTEHIDE_SECRETS_ENVIRONMENT=development# Linux/macOS
export BYTEHIDE_SECRETS_TOKEN=your-token-here
export BYTEHIDE_SECRETS_ENVIRONMENT=development
# Windows (Command Prompt)
set BYTEHIDE_SECRETS_TOKEN=your-token-here
set BYTEHIDE_SECRETS_ENVIRONMENT=developmentPHP Configuration
You can also set environment variables within PHP:
PHP
putenv('BYTEHIDE_SECRETS_TOKEN=your-token-here');
putenv('BYTEHIDE_SECRETS_ENVIRONMENT=production');putenv('BYTEHIDE_SECRETS_TOKEN=your-token-here');
putenv('BYTEHIDE_SECRETS_ENVIRONMENT=production');Production Environment
In production, set these variables through your hosting platform:
- Apache:
.htaccessorhttpd.confwithSetEnv - Nginx:
fastcgi_paramdirectives - Docker: Environment flags
- Laravel:
.envfile (managed by framework)
Verify Installation
After initializing the SDK, you can verify it's working by accessing a test secret:
PHP
<?php
require 'vendor/autoload.php';
use ByteHide\Secrets\SecretsManager;
try {
// Attempt to get a secret
$secret = SecretsManager::get('test');
echo "Secret retrieved successfully!\n";
} catch (\Exception $ex) {
echo "Error: " . $ex->getMessage() . "\n";
}<?php
require 'vendor/autoload.php';
use ByteHide\Secrets\SecretsManager;
try {
// Attempt to get a secret
$secret = SecretsManager::get('test');
echo "Secret retrieved successfully!\n";
} catch (\Exception $ex) {
echo "Error: " . $ex->getMessage() . "\n";
}