PHP code example of bnomei / kirby3-dotenv

1. Go to this page and download the library: Download bnomei/kirby3-dotenv 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/ */

    

bnomei / kirby3-dotenv example snippets



echo $_ENV['APP_MODE']; // production
echo env('APP_DEBUG');  // false
// or
echo $page->getenv('ALGOLIA_APIKEY');  // 12d7331...
echo $page->env('ALGOLIA_APIKEY');     // 12d7331...
echo site()->getenv('ALGOLIA_APIKEY'); // 12d7331...
echo site()->env('ALGOLIA_APIKEY');    // 12d7331...


echo $_ENV['APP_MODE']; // staging
echo env('APP_DEBUG');  // true
// ...


// `true` as default value
echo env('ALGOLIA_ENABLED', true);


return [
    // does not support callbacks
    // 'debug' => false, 

    // some plugins support callbacks for sensitive data options
    'bnomei.seobility.apikey' => function() { 
        return env('SEOBILITY_APIKEY'); 
    },
    
    // alternatively you can use the `ready` option
    // https://getkirby.com/docs/reference/system/options/ready
    'ready' => function() {
        return [
            'debug' => env('APP_DEBUG', false),
            'email' => [
                'transport' => [
                    'type' => 'smtp',
                    'host' => 'smtp.postmarkapp.com',
                    'port' => 587,
                    'security' => true,
                    'auth' => true,
                    'username' => env('POSTMARK_USERNAME'),
                    'password' => env('POSTMARK_PASSWORD'),
                ],
            ],
        ];
    }
];



v();

return [
    'debug' => env('APP_DEBUG', false),
    //...
];