2

I'm working on a project (Laravel 6) with multiple developers.

We run PHPUnit regularly when developing, and we have the .env.testing and phpunit.xml files committed to the repo so that all developers have the same testing environment defined.

We are now looking at how we could run PHPUnit on our development server as a final check. However, because the .env.testing and phpunit.xml files are geared to run on our local machines, how can I tell PHPUnit on the development server to use a separate .env file?

1 Answer 1

2

I don't really see the point of committing .env.testing, since it in my opinion defeats the purpose of .env files (setting different environment variables depending on your server / OS etc.).

At the moment you are locking your developers / server into using this specific .env file, so what I would recommend doing instead is the following:

I would remove .env.testing from your repo, add a new .env.testing.example that has all the default values that you need to run it locally, this allows every developer to copy the file to .env.testing while still allowing specfic enviroment values to be set by each developer, this will also allow you to have a custom .env.testing file for your development server.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer Remul. I was hoping to avoid that but it does makes sense and how we handle things with other environments.
Just as an additional suggestion on a detail here: Use the .dist suffix instead .example, this is more streamlined with phpunit itself which also has phpunit.xml.dist which you can put into the repository and every developer (user) of the project can create an override w/o the .dist extension. Make this visible in .gitignore, too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.