Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JennySwift's avatar

someone saw my .env file with my APP_KEY

Hi, I had a Codementor session with screen sharing and in the process of helping me my mentor saw my .env file which has my APP_KEY.

I don’t really understand what the APP_KEY is for so what I would like to know please, is could any harm be done as a result of it being seen? If yes, what harm could be done? And what should I do now, please?

0 likes
8 replies
janareit's avatar
Level 4

Just regenerate your key. No security risk then whatsoever.

Type php artisan key:generate to generate new key.

3 likes
bashy's avatar

And what about DB login details? Any other keys or passwords in there?

1 like
JennySwift's avatar

Thanks @bashy and @shahinul87. He only saw my local .env file so I figured no harm could be done from seeing the local db login details? My production environment variables are in Laravel Forge so he didn't see them. I just realized I don't have an APP_KEY environment variable for my production environment (because my APP_KEY is in my local .env file which gets ignored by git) and my app has been working fine without ever creating one. Should I have an APP_KEY for my production environment, too?

bashy's avatar

Okay, if it was local you don't need to worry about anything related to this file unless you had production credentials in it.

The APP_KEY should be separate to production so again, no harm.

1 like
JennySwift's avatar

That's a relief. Thanks @bashy, very helpful.

When you say the APP_KEY should be separate to production, do you mean I have a production APP_KEY somewhere? In Forge? Where would I find this please? I just want to know my production APP_KEY isn't the same as the APP_KEY he saw in my local .env file. When I ran php artisan key:generate to change it, I did that from homestead in the command line so I suppose that wouldn't have changed my production APP_KEY (if it exists).

bashy's avatar

No problem!

I've not used Forge myself but you should set the environment variables somewhere (including the APP_KEY). It's along with all the DB credentials as well.

1 like

Please or to participate in this conversation.