-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variable not found since symfony 5.1 #126
Comments
I found the problem Here's how to fix it: In friends-of-behat/symfony-extension/src/ServiceContainer/SymfonyExtension.php
But it will have to be done more cleanly |
Great! Thanks @jfsenechal |
Solution without hacking vendors: behat.yaml default:
extensions:
FriendsOfBehat\SymfonyExtension:
bootstrap: 'config/behat/bootstrap.php'
# ... config/behat/bootstrap.php <?php
(new Symfony\Component\Dotenv\Dotenv())->bootEnv(dirname(__DIR__, 2).'/.env'); |
Another idea I've used: the PHPUnit stuff still ships a bootstrap.php which either uses config/bootstrap.php or DotEnv loading. I've referenced this in behat.yaml and now both testing tools use the same bootstrap.php |
In my opinion, this should become a part of symfonyextension's documentation regarding handling environment variable. Thanks BTW |
Any clean solutions please ? |
Pr is ready #127 |
How would you determine that a solution is "clean"? What's wrong with the given examples? |
The amount of effort to resolve a problem can easily determine if the solution if clean or not. Regarding the given examples nothing wrong with them , they already solve the problem. thanks. |
Side note here. Whilst you have the phpunit already installed, its recipe provides the I've used it in the
Why not to use the same approach and just to provide a recipe that will provide the file or just update the docs? |
hi there, as today this still an issue? I am trying to run/debug Behat Scenarios using PhpStorm and I am getting the same exact error as everyone here. Also what should I do if I do not have such |
IMHO, the best solution remains to introduce the environment variables loading in the extension This because if you did not set the Take care to always run Behat with:
|
@b2p-fred I running Behat same as in your example but for some reason, PhpStorm does not see the variables defined at |
@reypm I do not use PHPStorm to run the Behat tests. As such, sorry, I cannot help ... |
You can set it in once in behat.yaml default:
extensions:
FriendsOfBehat\SymfonyExtension:
# the "bootstrap" line is a fix for error: Environment variable not found: "DATABASE_URL".
bootstrap: 'tests/bootstrap.php'
kernel:
environment: 'test'
debug: true |
Hello
Since symfony 5.1 when running vendor / bin / behat there is an error message
To reproduce the error, just install a new application in 5.1
Here are my composer depedencies :
The text was updated successfully, but these errors were encountered: