Skip to content

Configuration

Igor Sazonov edited this page Jan 31, 2026 · 3 revisions

Configuration

Properly configuring the bybit-php library is essential for connecting to the Bybit API. This guide covers the configuration for both standalone PHP projects and Laravel applications.

Standalone PHP Configuration

For projects that do not use Laravel, you can instantiate the BybitClient class directly. The constructor accepts your API key, secret, and other configuration options.

use Tigusigalpa\ByBit\BybitClient;

$apiKey = 'your-api-key';
$apiSecret = 'your-api-secret';

$client = new BybitClient(
    apiKey: $apiKey,
    apiSecret: $apiSecret,
    testnet: true // Use the testnet
);
Parameter Type Default Description
apiKey string Your Bybit API key.
apiSecret ?string null Your Bybit API secret.
testnet bool false Set to true to use the testnet environment.
demoTrading bool false Set to true to use the demo trading environment.
region string global The regional endpoint to use.
recvWindow int 5000 The request receive window in milliseconds.
signature string hmac The signature method (hmac or rsa).
rsaPrivateKey ?string null Your RSA private key if using RSA signature.

Laravel Configuration

For Laravel applications, the recommended way to configure the library is by using environment variables.

1. Publish the Configuration File

If you haven't already, publish the configuration file:

php artisan vendor:publish --tag=bybit-config

This creates the config/bybit.php file, which reads the settings from your .env file.

2. Set Environment Variables

Add your Bybit API credentials and other settings to your .env file:

BYBIT_API_KEY=your_api_key_here
BYBIT_API_SECRET=your_api_secret_here
BYBIT_TESTNET=true
BYBIT_REGION=global
BYBIT_SIGNATURE=hmac

The library will automatically use these settings when you use the Bybit facade or inject the client through the service container.

Next Steps

With the library configured, you are now ready to start making API calls. Proceed to the Quick Start guide for a hands-on example.

Clone this wiki locally