#m2.0

1 messages · Page 1 of 1 (latest)

gleaming pendantBOT
short quarry
#

Hello! Can you confirm that line 8 of index.php looks like this?

$dotenv = Dotenv\Dotenv::create(__DIR__);
gaunt folio
#

Hello
Yes I confirm it

short quarry
#

What version of PHP are you using?

gaunt folio
#

I'm using php 8, should I use another one?

short quarry
#

That should be fine. That's a strange error. What version of phpdotenv got installed?

gaunt folio
#

It looks to me like it's the version listed in the composer file...I just did the command 'composer install'

short quarry
#

And you copied the .env.example file to .env and changed the content?

gaunt folio
#

Yes that's right, I did everything as instructed.
here is a screenshot of the folders.
I may have made a mistake, do you see a problem?

short quarry
#

You need to move .env inside the php directory.

#

Or you need to change line 8 to point to the .env file in its current location.

gaunt folio
#

I actually moved the .env to the server directory as you can see in the 2nd screenshot...

Please excuse my amateurism, could you give me an example to point line 8 to the env file

short quarry
#

Wait, sorry, I think I got confused there. So you have the .env file alongside the index.php file, correct?

#

And running the sample still shows the same error as before?

gaunt folio
#

Exactly the error is still present

#

the same error ... I've been on it for a few hours and I don't understand where the problem comes from

short quarry
#

Still looking...

gaunt folio
#

do you encounter this problem if you install this sample?

short quarry
#

Just trying that now... and I do get the same error! Interesting...

#

Looks like this code is a bit out of date, give me a few minutes...

gaunt folio
#

Very well thank you

short quarry
#

It looks like the versions in the composer.json file were changed unexpectedly. This is what should be in composer.json:

{
    "require": {
        "slim/slim": "^3.12",
        "vlucas/phpdotenv": "^3.4",
        "stripe/stripe-php": "^7.7.1",
        "monolog/monolog": "^1.17"
    },
    "scripts": {
        "start": "php -S localhost:4242 index.php"
    }
}
#

Once you update that, delete the vendor and composer.lock files, then run composer install again and see if that gets things working.

gaunt folio
#

I will try this

#

You are a boss! 🙂