9

I am currently building a website and just created a Docker environment for it (witch is working pretty good). My docker-compose.yml file looks like this:

version: '3.1'
services:
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./wp-content:/var/www/html/wp-content
    environment:
      WORDPRESS_DB_NAME: database
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: mypassword
      WORDPRESS_TABLE_PREFIX: wp_
      WORDPRESS_CONFIG_EXTRA:
        define( 'WP_DEBUG', true );
    ports:
      - 9000:80
      - 443:443
    networks:
      - back
  db:
    image: mysql:5.7
    restart: unless-stopped
    volumes:
       - db_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: mypassword
    networks:
      - back
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: mypassword
    networks:
      - back
networks:
  back:
volumes:
  db_data:

Now I'm working on a plugin, but it's not working. Normally I would see some PHP errors, but now I don't see any. I don't have a wp-config.php file, because my docker-container creates one for me.

When I searched for it, I read that I need to add WORDPRESS_CONFIG_EXTRA and could add some code in there, then Docker would add that to my wp-config file. But this doesn't seem to work.

Does anyone know what I'm doing wrong?

Thanks in advance!

Loosie94
  • 574
  • 8
  • 17
  • Possibly related: https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1 – KDecker Apr 01 '19 at 19:36

1 Answers1

6

Try using WORDPRESS_DEBUG instead. Like this

environment:
      WORDPRESS_DB_HOST: "mysql"
      WORDPRESS_DB_NAME: "wordpress"
      WORDPRESS_DB_PASSWORD: "testing"
      WORDPRESS_DB_USER: "root"
      WORDPRESS_DEBUG: 1

It adds define( 'WP_DEBUG', true ); to your wp-config.php

Also the reason for WORDPRESS_CONFIG_EXTRA not working is because your forgot the |.

This is the correct way.

WORDPRESS_CONFIG_EXTRA: |
    define( 'WP_DEBUG', true );
NEXT_VAR: false

| tells yml that the value is gonna be a gonna take up the succeeding lines. Note: the indentation it's important here.

Geoff Taylor
  • 496
  • 3
  • 17
  • Hi Geoff, thanks for your response. It seems to be the plugin itself that was hiding errors. You are still the accepted answer, because this did the trick in other php files. Thanks! – Loosie94 Apr 03 '19 at 18:04
  • Thanks, first suggestion works like a charm – motizukilucas Oct 09 '21 at 22:08