I'm using the PhpStorm IDE and I installed dotenv on the server via SSH. Subsequently I didn't have the new vendor files in the local directory which caused this error. I simply downloaded the up-to-date vendor folder from the server (overwriting the local one) and the error went away.