I was given a docker-compose.yml file from the agency that created our website in order to build a local dev copy of our existing website now that I've taken over managing our Wordpress e-com.
Proceeding to run docker-compose up
, both the website and database containers launch without any warnings (other than apache2 not having a set server name) and when I go to localhost in my browser I can communicate with the server instance, however I am greeted by the following message:
Fatal error: Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string given, called in /var/www/config/application.php on line 8 and defined in /var/vendor/vlucas/phpdotenv/src/Dotenv.php:31 Stack trace: #0 /var/www/config/application.php(8): Dotenv\Dotenv->__construct('/var/www') #1 /var/www/public/wp-config.php(14): require_once('/var/www/config...') #2 /var/www/public/wp/wp-load.php(42): require_once('/var/www/public...') #3 /var/www/public/wp/wp-blog-header.php(13): require_once('/var/www/public...') #4 /var/www/public/index.php(5): require('/var/www/public...') #5 {main} thrown in /var/vendor/vlucas/phpdotenv/src/Dotenv.php on line 31```
Figuring this was a problem with the .env file itself, I recreated it since it contains only a very few simple lines (modified the values for sharing on here, otherwise identical):
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=wordpressdb
MYSQL_USER=wordpressuser
MYSQL_PASSWORD=wordpresspassword
No matter where I put this .env file, it seems to give me the same Fatal error.
Thinking it might be that I didn't have dotenv installed properly, I went back to basics and made sure Composer had everything it needed. My composer.json file lists the following required dependencies:
"php": ">=5.5",
"composer/installers": "^1.2",
"vlucas/phpdotenv": "^3.4",
"johnpbloch/wordpress": "^4.9.5",
"wpackagist-plugin/timber-library": "1.1.*",
"wpackagist-plugin/woocommerce": "3.4.7",
"wpackagist-plugin/advanced-custom-fields-table-field": "1.*",
"wpackagist-plugin/woocommerce-email-test": "^1.8",
"wpackagist-plugin/woocommerce-pdf-invoices-packing-slips": "^2.0.9",
"wpackagist-plugin/redirection": "^3.4",
"wpackagist-plugin/relevanssi": "^4.0",
"wpackagist-plugin/acf-gravityforms-add-on": "^1.2",
"wpackagist-plugin/woocommerce-product-price-based-on-countries": "^1.7",
"wpackagist-plugin/acf-content-analysis-for-yoast-seo": "^2.1",
"wpackagist-plugin/autoptimize": "^2.3",
"wpackagist-plugin/w3-total-cache": "^0.9.7",
"wpackagist-plugin/post-types-order": "1.9.3.9",
"wpackagist-plugin/amazon-s3-and-cloudfront":"^2.0",
"phpoption/phpoption": "^1.5",
"symfony/polyfill-ctype": "^1.11",
"symfony/dotenv": "^4.3"
When I run composer show -i
it shows that they are all installed.
Expected results: I should be viewing a local copy of our Wordpress on localhost so that I can develop and then push changes to docker hub.
Actual Results: There are no CLI errors when building from the docker-compose.yml, but when I access localhost
I receive the dotenv-related error message shown above.
This is really stumping me - if anyone can shed some light on the situation I would be infinitely grateful!