Passing a boolean to the constructor of “Symfony\Component\Dotenv\Dotenv” is deprecated

You might encounter this deprecation message after your upgrade to symfony 5.1 in your symfony project:

Since symfony/dotenv 5.1: Passing a boolean to the constructor of “Symfony\Component\Dotenv\Dotenv” is deprecated, use “Dotenv::usePutenv()

To fix this, go to config/bootstrap.php and remove the false from the Dotenv constructor:
(new Dotenv(false))->loadEnv(dirname(DIR).'/.env');
to
(new Dotenv())->loadEnv(dirname(DIR).'/.env');
See: https://github.com/symfony/symfony/issues/37195

Actually the file config/bootstrap.php has been removed from symfony 5.1 and was replaced in public/index.php.

But since the project was updated from an symfony 4 version the bootrap file is still present.

So another option would be to remove the boostrap file and update the project entirely to symfony 5.1 recipe.
This is not trivial though as you can see in this corresponfing PullRequest.

Docker-compose and Unknown MySQL server host

In case you encounter this error with mysql and your docker-compose setup:

Unknown MySQL server host <mysql-service-name>Code language: HTML, XML (xml)

… and you dont know why because everything seems to be correct.

Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.
This can happen when you use a unspecified tag as mysql:latest (not recommended anyway) and there was a version bump in the official mysql image.
Or you upgraded the mysql container yourself, f.e. from mysql:5.6 to mysql:5.7 and you are reusing the data volume with the mysql files.

Continue reading “Docker-compose and Unknown MySQL server host”

Psalm Static Analyzer fails with Symfony’s builtin preloading file

So i updated a symfony app the other day to version 5.1.6 and suddenly the static code analyzer psalm ran appearently in an hangup loop and never terminated.

After some investigation it showed that symfony added a .preload.php file to the src directory to enable the new PHP7.4 preloading feature.

Unfortunatly psalm parsed this file and followed all includes.
This took it so long that i took it for an endless loop.

There is some discussion in symfony github issues about this and the conclusion was to replace src/.preload.php with config/preload.php which happens now in a recipe.

Continue reading “Psalm Static Analyzer fails with Symfony’s builtin preloading file”

Umlaut domain problems

Living in an umlaut country like Germany umlaut domains are sometimes requested.
But: Umlaut domains resp. Internationalized Domain Names (IDN) are problematic.

My main pain points were these:

  1. Browsers tend to convert the unicode representations to ASCII Compatible Encoding (ACE) with punycode representations for security reasons when copying the url.
    So you will get a nice surprise when pasting the url somewhere:

F.e. having https://hürth-blüht.de/ in the browsers address bar will get you https://xn--hrth-blht-q9ag.de/ on copy/paste.
This punycode representation is very unfamiliar to normal users and will keep them from clicking the url because it looks suspicious.

Continue reading “Umlaut domain problems”

Updating OXID eShop to 6.2.0

Oxid eShop 6.2 is released and its a good step forward to a modernized codebase, embracing best practices and more symfony-like patterns.

Since i do a lot of coding with symfony besides OXID i was very exited about this new version. So i gave it a try and updated one of the shops i maintain. (Its not public yet, i will update this post once we launch, Its launched by now, yay: https://www.cafelehmitz-photobooks.com/).

I basically followed this upgrade guide: https://docs.oxid-esales.com/eshop/de/6.2/installation/update/von-6.1.x-auf-6.2.0-aktualisieren.html

So here is my experience updating OXID eShop 6.1.5 to 6.2.0:

Continue reading “Updating OXID eShop to 6.2.0”

Adminer for Sqlite in Docker

Recently i wanted to use Sqlite with Adminer in Docker and it turned out to be not so easy.
I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql.

Update: Today i would rather use the IntelliJ Database Tool for Sqlite administration.

But since Adminer is a popular hacking target they introduced a feature that does not allow to run adminer without a password, out of the box.
Sqlite database usually runs without password and dang, workaround needed!

Continue reading “Adminer for Sqlite in Docker”

Disable symfony deprecation warnings in PHPUnit tests

Symfony’s deprecation warnings while running tests is a great service to keep track with upcoming changes in newer symfony versions.
However these warnings can break your CI/CD pipeline and sometimes you cant fix all deprecation warnings immediatly.

To disable them you can set the ENV var
SYMFONY_DEPRECATIONS_HELPER=disabled
and the warnings will not be displayed anymore and CI/CD will pass again.
Update from comments:

SYMFONY_DEPRECATIONS_HELPER=weak
does also work and will still show the deprecation warnings count. (Thx Max)

Continue reading “Disable symfony deprecation warnings in PHPUnit tests”