PHP code example of beacon-hq / pennant-driver

1. Go to this page and download the library: Download beacon-hq/pennant-driver 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/ */

    

beacon-hq / pennant-driver example snippets




return [
    'default' => env('PENNANT_STORE', 'beacon'),

    'stores' => [
        'beacon' => [
            'driver' => 'beacon',
            'app_name' => env('BEACON_APP_NAME', env('APP_NAME', 'Laravel')),
            'environment' => env('BEACON_ENVIRONMENT', env('APP_ENV', 'local')),
            'url' => env('BEACON_API_URL', 'https://api.beaconhq.io/'),
            'path_prefix' => env('BEACON_API_PATH_PREFIX', '/api'),
            'cache_store' => env('BEACON_CACHE_STORE', config('cache.default', 'array')),
            'cache_ttl' => env('BEACON_CACHE_TTL', 1800),
            'api_key' => env('BEACON_ACCESS_TOKEN'),
            'api_timeout' => env('BEACON_API_TIMEOUT', 3000),
        ],
    ],
];

use Laravel\Pennant\Feature;

// Check if a feature is active
if (Feature::active('new-dashboard')) {
    // Show new dashboard
}

// Check if a feature is inactive
if (Feature::inactive('legacy-feature')) {
    // Hide legacy feature
}

use Laravel\Pennant\Feature;

// Check feature for a specific user
$user = auth()->user();
if (Feature::for($user)->active('premium-features')) {
    // Show premium features
}

// Check feature for a team
$team = $user->team;
if (Feature::for($team)->active('team-collaboration')) {
    // Enable team collaboration features
}

use Laravel\Pennant\Feature;

// Get feature value (boolean, string, array, etc.)
$config = Feature::value('feature-config');

use Laravel\Pennant\Feature;

// Execute code when feature is active
Feature::when('new-feature', function () {
    // Code to run when feature is active
}, function () {
    // Code to run when feature is inactive (optional)
});