PHP code example of xiaoniuge / think-dotenv

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

    

xiaoniuge / think-dotenv example snippets

 php
// 自定义 .env
if (getenv('RUNTIME_ENVIRONMENT')) {
   $env = '.'.getenv('RUNTIME_ENVIRONMENT'); 
} else {
   $env = '.env';
}

$env_file = $path.'/'.$env;

    return array(
         'app_init'=>array(
            'Snowair\Think\Behavior\HookAgent'
         ),
    )
    

config.php

return array(
        'DB_TYPE'   => 'mysql', // 数据库类型
        'DB_HOST'   => 'localhost', // 服务器地址
        'DB_NAME'   => 'dbname', // 数据库名
        'DB_USER'   => 'root', // 用户名
        'DB_PWD'    => '123456', // 密码
        'DB_PORT'   => 3306, // 端口
        'DB_PREFIX' => '', // 数据库表前缀
);