Loading constants and environment variables from .env files.
Requirements:
- php ^7.2.5
$ composer require zippovich2/wordpress-loader
Add code at beginning in wp-config.php
:
use WordpressWrapper\Loader\Loader;
//...
$loader = new Loader();
$loader->load();
You can specify own paths:
use WordpressWrapper\Loader\Loader;
//...
$projectRoot = '/path/to/project-root/'; // this directory should containt .env files.
$public = $projectRoot . '/public'; // this directory should containt index.php file
$wpCore = '/wp'; // relevant path from $public to wordpress core directory
$loader = new Loader();
$loader->load($wpCore, $projectRoot, $public);
If you want to enable debug add one more line:
use WordpressWrapper\Loader\Loader;
//...
$loader = new Loader();
$loader->load();
// default path is '/var/log', relevant ro project root
// it will create directroy if not exists
$loader->debugSettings('/path/to/log/dir');