fortrabbit / craft-copy

Deployment tools for Craft on fortrabbit
https://www.fortrabbit.com
MIT License
73 stars 8 forks source link

Deprecation error from dependency `vlucas/phpdotenv` #170

Closed turnstylerj closed 1 year ago

turnstylerj commented 1 year ago

Issue

On an existing Fortrabbit site running in a local environment (ddev), craft-copy commands such as ddev exec php craft copy/db/down work, but I'm seeing the following error from a craft-copy dependency on the command line after running composer install and on the front end/CP of the website:

Deprecated: auto_detect_line_endings is deprecated in /var/www/html/vendor/vlucas/phpdotenv/src/Loader.php on line 172

This error is not shown on the Fortrabbit version of the site, though the same PHP/plugin versions are used in both environments. Out of curiosity, I also tried spinning the site up in MAMP and was getting the same error.

Details

The current server setup/versions in both environments are as follows:

PHP | 8.1 Database | MySQL 8.0 Craft CMS | 3.7.67 Copy | 1.2.4 vlucas/phpdotenv | ^2.4.0

I can resolve this error locally by doing the following:

With those changes, I can load the site front end and CP with no issues locally, but ddev exec php craft copy/db/down now fails with:

PHP Fatal error:  Uncaught TypeError: Dotenv\Dotenv::__construct(): Argument #1 ($loader) must be of type Dotenv\Loader, string given, called in /var/www/html/craft on line 16 and defined in /var/www/html/vendor/vlucas/phpdotenv/src/Dotenv.php:31

I'm unsure how to proceed here. Is there a way to resolve the original error without updating the PHP/vlucas/phpdotenv versions?

ostark commented 1 year ago

Hi

the linked issue is definitely in the right direction. The issue is not related to Craft Copy at all, but to outdated dependencies of your Craft site.

To fix the problem you need to change the version of the dotenv lib in your composer.json

"vlucas/phpdotenv": "^5.4.0"

and update the web/index.php AND the craft file https://github.com/craftcms/craft/blob/1.1.7/craft