/

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:

Bash
composer require bytehide/secrets

Manual Installation

Download the source and include the autoloader:

PHP
require 'path/to/bytehide-secrets/vendor/autoload.php';

Initialize the SDK

Once installed, you need to initialize the SDK with your project token.

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";

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');

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

PHP Configuration

You can also set environment variables within PHP:

PHP
putenv('BYTEHIDE_SECRETS_TOKEN=your-token-here');
putenv('BYTEHIDE_SECRETS_ENVIRONMENT=production');

Production Environment

In production, set these variables through your hosting platform:

  • Apache: .htaccess or httpd.conf with SetEnv
  • Nginx: fastcgi_param directives
  • Docker: Environment flags
  • Laravel: .env file (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";
}

Next Steps

Previous
CI/CD Integration