zippovich2/wordpress-loader

Loading constants and environment variables from .env files.

v1.1.2 2023-01-16 11:47 UTC

This package is auto-updated.

Last update: 2024-10-16 15:42:25 UTC


README

Loading constants and environment variables from .env files.

Build Status Packagist

Installation

Requirements:

  • php ^7.2.5
$ composer require zippovich2/wordpress-loader

Usage

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');