papertank / envoy-deploy

Laravel Envoy Deployment
MIT License
424 stars 85 forks source link

Dotenv must be an instance of repositoryInterface #15

Closed Bluefitdev closed 4 years ago

Bluefitdev commented 4 years ago

Hi There,

Why is this happening?

My laravel version is 7

╰ envoy run deploy
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::create() must be an instance of Dotenv\Repository\RepositoryInterface, string given, called in /mnt/d/Personal Documents/Career/Bluefit/repos/salt-backend/Envoy9fa9ff7f759fea3ad676b08c50729eca.php on line 15 and defined in /mnt/d/Personal Documents/Career/Bluefit/repos/salt-backend/vendor/vlucas/phpdotenv/src/Dotenv.php:62
Stack trace:

It was fine for me on laravel 6.. probably because the dotenv version is changed in laravel 7?

Thanks

WbTOne commented 4 years ago
@setup
    $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
    try {
        $dotenv->load();
        $dotenv->required(['DEPLOY_PATH'])->notEmpty();
    } catch ( Exception $e )  {
        echo $e->getMessage();
    }
@endsetup
davidrushton commented 4 years ago

Thanks for the heads up and apologies for the delay in fixing. The latest version (3.0) fixes this by upgrading phpdotenv to ^4.0 which Laravel 7 uses.

If you have this issue in an existing Laravel 7 project, @WbTOne fix above is all you need.

If you need to use this Envoy script in a new Laravel 5 or 6 project, the readme has the v2 file you need: https://github.com/papertank/envoy-deploy#laravel-5-6