PHP code example of rpdvlpr / configcat-laravel

1. Go to this page and download the library: Download rpdvlpr/configcat-laravel 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/ */

    

rpdvlpr / configcat-laravel example snippets


// config/app.php
'providers' => array(
    // ...
    Rpdvlpr\Config\ConfigCatServiceProvider::class,
);

// config/app.php
'aliases' => [
    // ...
    'ConfigCat' => Rpdvlpr\Config\Facade\ConfigCat::class,
];

# .env
# ...
CONFIGCAT_API_KEY=#YOUR-API-KEY#
CONFIGCAT_AUTH_CLASS="\Auth"        # optional, uses default Auth facade
CONFIGCAT_AUTH_METHOD="user"        # optional, uses default user method
CONFIGCAT_USER_IDENTIFIER="id"      # optional, uses default User id
CONFIGCAT_USER_METHOD="toArray"     # optional, uses default toArray method
CONFIGCAT_CACHE_REFRESH_INTERVAL=60 # optional, defaults to 60 seconds
CONFIGCAT_REQUEST_TIMEOUT=30        # optional, defaults to 30 seconds
CONFIGCAT_CONNECT_TIMEOUT=10        # optional, defaults to 10 seconds

$isMyAwesomeFeatureEnabled = \ConfigCat::getValue("isMyAwesomeFeatureEnabled");
if(is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) {
    doTheNewThing();
} else {
    doTheOldThing();
}
shell
php artisan vendor:publish