src/config/application.php
changeset 39 5a716b5cfe09
parent 0 800e4a6ab128
equal deleted inserted replaced
38:c6ce67c1ec54 39:5a716b5cfe09
     7  * possible. Try to define as much of your configuration in this file as you
     7  * possible. Try to define as much of your configuration in this file as you
     8  * can.
     8  * can.
     9  */
     9  */
    10 
    10 
    11 use Roots\WPConfig\Config;
    11 use Roots\WPConfig\Config;
       
    12 use function Env\env;
    12 
    13 
    13 /** @var string Directory containing all of the site's files */
    14 /** @var string Directory containing all of the site's files */
    14 $root_dir = dirname(__DIR__);
    15 $root_dir = dirname(__DIR__);
    15 
    16 
    16 /** @var string Document Root */
    17 /** @var string Document Root */
    17 $webroot_dir = $root_dir . '/web';
    18 $webroot_dir = $root_dir . '/web';
    18 
    19 
    19 /**
    20 /**
    20  * Expose global env() function from oscarotero/env
       
    21  */
       
    22 Env::init();
       
    23 
       
    24 /**
       
    25  * Use Dotenv to set required environment variables and load .env file in root
    21  * Use Dotenv to set required environment variables and load .env file in root
    26  */
    22  */
    27 $dotenv = Dotenv\Dotenv::create($root_dir);
    23 $dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir);
    28 if (file_exists($root_dir . '/.env')) {
    24 if (file_exists($root_dir . '/.env')) {
    29     $dotenv->load();
    25     $dotenv->load();
    30     $dotenv->required(['WP_HOME', 'WP_SITEURL']);
    26     $dotenv->required(['WP_HOME', 'WP_SITEURL']);
    31     if (!env('DATABASE_URL')) {
    27     if (!env('DATABASE_URL')) {
    32         $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']);
    28         $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']);
    33     }
    29     }
    34 }
    30 }
       
    31 
    35 
    32 
    36 /**
    33 /**
    37  * Set up our global environment constant and load its config first
    34  * Set up our global environment constant and load its config first
    38  * Default: production
    35  * Default: production
    39  */
    36  */
    96 
    93 
    97 /**
    94 /**
    98  * Debugging Settings
    95  * Debugging Settings
    99  */
    96  */
   100 Config::define('WP_DEBUG_DISPLAY', false);
    97 Config::define('WP_DEBUG_DISPLAY', false);
       
    98 Config::define('WP_DEBUG_LOG', env('WP_DEBUG_LOG') ?? false);
   101 Config::define('SCRIPT_DEBUG', false);
    99 Config::define('SCRIPT_DEBUG', false);
   102 ini_set('display_errors', 0);
   100 ini_set('display_errors', 0);
   103 
   101 
   104 /**
   102 /**
   105  * Allow WordPress to detect HTTPS when used behind a reverse proxy or a load balancer
   103  * Allow WordPress to detect HTTPS when used behind a reverse proxy or a load balancer