Skip to content

Configure all wp-config.php variable with Docker environment variables ? #200

Closed
@harobed

Description

@harobed

What do you think about configure wp-config.php with Docker environment variables ?

Like this:

<?php

define('WP_CONTENT_DIR', '/var/www/wp-content');

$table_prefix  = getenv('TABLE_PREFIX') ?: 'wp_';

foreach ($_ENV as $key => $value) {
  $capitalized = strtoupper($key);
  if (!defined($capitalized)) {
    define($capitalized, $value);
  }
}

if (!defined('ABSPATH'))
    define('ABSPATH', dirname(__FILE__) . '/');

require_once(ABSPATH . 'wp-settings.php');
?>

source: https://codeable.io/wordpress-developers-intro-to-docker-part-two/#configuring-wp-configphp

It is useful for instance to configure FS_METHOD=direct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions