jakemackie / wordpress

A full stack web social platform as a way of learning Wordpress
2 stars 0 forks source link

Issue with wp-config #13

Closed jakemackie closed 3 weeks ago

jakemackie commented 3 weeks ago

Now that all Docker images are starting successfully, I turn to wp-config. I don't think it's reading envrionment variables correctly.

alfiephillips commented 3 weeks ago

Use of get_env() in wp_config may be returning null, depending on if it can access the environment in the project root i'm not sure.

jakemackie commented 3 weeks ago

Use of get_env() in wp_config may be returning null, depending on if it can access the environment in the project root i'm not sure.

I hard coded it and it's no difference. What is interesting are the debug lines I added to the setup script, and you can clearly see:

2024-06-10 19:26:44 Starting setup script...
2024-06-10 19:26:44 Checking for required environment variables...
2024-06-10 19:26:44 WORDPRESS_DB_HOST: db:3306
2024-06-10 19:26:44 WORDPRESS_DB_USER: wordpress
2024-06-10 19:26:44 WORDPRESS_DB_PASSWORD: wordpress
2024-06-10 19:26:44 WORDPRESS_DB_NAME: wordpress
2024-06-10 19:26:44 mysqld is alive
2024-06-10 19:26:44 Database connection established.
2024-06-10 19:26:44 Creating database if it doesn't exist...
2024-06-10 19:26:44 Verifying database creation and permissions...
2024-06-10 19:26:44 Database wordpress exists and is accessible.
2024-06-10 19:26:44 Setup complete. Starting Apache..

image

jakemackie commented 3 weeks ago

Use of get_env() in wp_config may be returning null, depending on if it can access the environment in the project root i'm not sure.

I hard coded it and it's no difference. What is interesting are the debug lines I added to the setup script, and you can clearly see:

2024-06-10 19:26:44 Starting setup script...
2024-06-10 19:26:44 Checking for required environment variables...
2024-06-10 19:26:44 WORDPRESS_DB_HOST: db:3306
2024-06-10 19:26:44 WORDPRESS_DB_USER: wordpress
2024-06-10 19:26:44 WORDPRESS_DB_PASSWORD: wordpress
2024-06-10 19:26:44 WORDPRESS_DB_NAME: wordpress
2024-06-10 19:26:44 mysqld is alive
2024-06-10 19:26:44 Database connection established.
2024-06-10 19:26:44 Creating database if it doesn't exist...
2024-06-10 19:26:44 Verifying database creation and permissions...
2024-06-10 19:26:44 Database wordpress exists and is accessible.
2024-06-10 19:26:44 Setup complete. Starting Apache..

image

Adding to this - the .env file isn't needed. The variables in the compose file are being recognised in all areas of the app, apart from wp-config, I believe.

alfiephillips commented 3 weeks ago

Use of get_env() in wp_config may be returning null, depending on if it can access the environment in the project root i'm not sure.

I hard coded it and it's no difference. What is interesting are the debug lines I added to the setup script, and you can clearly see:


2024-06-10 19:26:44 Starting setup script...

2024-06-10 19:26:44 Checking for required environment variables...

2024-06-10 19:26:44 WORDPRESS_DB_HOST: db:3306

2024-06-10 19:26:44 WORDPRESS_DB_USER: wordpress

2024-06-10 19:26:44 WORDPRESS_DB_PASSWORD: wordpress

2024-06-10 19:26:44 WORDPRESS_DB_NAME: wordpress

2024-06-10 19:26:44 mysqld is alive

2024-06-10 19:26:44 Database connection established.

2024-06-10 19:26:44 Creating database if it doesn't exist...

2024-06-10 19:26:44 Verifying database creation and permissions...

2024-06-10 19:26:44 Database wordpress exists and is accessible.

2024-06-10 19:26:44 Setup complete. Starting Apache..

image


define('DB_HOST', getenv('WORDPRESS_DB_HOST'));

I think the DB_HOST is meant to be localhost:{port number for database} but at the moment it reads db:3306, which isn't right because that's used for the docker image this won't work in the wordpress config.

alfiephillips commented 3 weeks ago

Closing this issue as removing all processes including docker and reverting to using XAMPP server.