Skip to content

Laravel Configuration

Laravel uses the exact same Config resolution and environment variables described in Configuration — nothing about the options themselves changes inside Laravel. This page covers the parts specific to the framework: publishing the config file and where .env fits in.

Environment variables

Add your device details to your Laravel app's .env:

dotenv
BIOTIME_IP=192.168.1.50
BIOTIME_PORT=8081
BIOTIME_USERNAME=admin
BIOTIME_PASSWORD=secret
BIOTIME_HTTPS=false
BIOTIME_TIMEOUT=15

WARNING

If you haven't published config/biotime.php (see below), the SDK falls back to reading these directly via Config::fromEnv(). Note the BIOTIME_VERIFY_HTTPS caveat described on the Configuration page — publishing the config file avoids that inconsistency, since the published file reads BIOTIME_VERIFY_HTTPS explicitly.

Publishing the config file

If you'd rather have an explicit, editable config file (Laravel's usual convention) instead of relying solely on raw env-var fallbacks:

bash
php artisan vendor:publish --tag=biotime-config

This copies the package's src/config/biotime.php into your app's config/biotime.php, where Laravel merges in .env values as usual through the file's own $_ENV/getenv() fallbacks.

Custom wiring

You only need to register your own binding manually if you want non-default wiring — for example, a specific cache store other than Laravel's default, or a custom Guzzle client (for logging/middleware). Override the container binding in your own service provider:

php
use BioTime\BioTime;
use BioTime\Config;

$this->app->singleton(BioTime::class, function ($app) {
    return new BioTime(
        Config::fromArray([
            'ip'       => config('biotime.ip'),
            'port'     => config('biotime.port'),
            'username' => config('biotime.username'),
            'password' => config('biotime.password'),
            'cache'    => $app['cache']->store('redis'),
        ])
    );
});

Next step

Continue to Laravel usage.

Distributed under the MIT License.