Skip to content
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: "DATABASE_URL". #159

Open
ahmedtoolapp opened this issue Jul 10, 2020 · 4 comments
Open

Environment variable not found: "DATABASE_URL". #159

ahmedtoolapp opened this issue Jul 10, 2020 · 4 comments

Comments

@ahmedtoolapp
Copy link

I am using Symfony2Extension with a new installation of Symfony 5.1 with PHP 7.3
I tried to launch vendor/bin/behat

I have my feature displayed but with an error

In EnvVarProcessor.php line 171:
Environment variable not found: "DATABASE_URL".
@kadzany
Copy link

kadzany commented Sep 8, 2020

Have you solved this issue @ahmedtoolapp ?

@mtarld
Copy link

mtarld commented Oct 11, 2020

This error means that the bootstrap file isn't loaded. Indeed, the boostrap.php is responsible to load the Symfony's DotEnv component.

Therefore, have a look at your behat.yml file and make sure that the bootstrap file path is correctly configured.

Eg:

extensions:
    Behat\Symfony2Extension:
        kernel:
            bootstrap: features/bootstrap/bootstrap.php
            class: App\Kernel

@denys999
Copy link

denys999 commented Dec 8, 2020

@ And how to connect Database ? How it looks like in FeatureContext ?
function () { new Kernel ....

@mrmkrs
Copy link

mrmkrs commented Apr 25, 2024

For what it's worth, I've stumbled upon this issue too and using the comment of @mtarld I got it fixed (I was working on a symfony 6.4 to symfony 7 upgrade)

The error

In EnvVarProcessor.php line 217:
                                                                          
  [Symfony\Component\DependencyInjection\Exception\EnvNotFoundException]  
  Environment variable not found: "MYSQL_HOST".                           

The fix

        FriendsOfBehat\SymfonyExtension:
-            path: src/App/Kernel.php
+            path: tests/bootstrap.php

contents of bootstrap.php

<?php

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
    require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
    (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants