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

ynoth25's avatar

Laravel & Git

I created a remote repository using "git init --bare" and pushed the Laravel files into it. But after I pull the contents of the repository, I encountered this error: Uncaught ReflectionException: Class env does not exist in C:\Users\Secret \Desktop\docker_repo\src\vendor\laravel\framework\src Illuminate\Container\Container.php:873

0 likes
11 replies
bugsysha's avatar

Have you done composer install? Every .gitignore file that comes with Laravel vendor directory is excluded. So when you push your code, you need to do the "reinstall" of the app. Probably besides that you would have to cp .env.example .env and php artisan key:generate to set up initial things. Note that you might have to set up in .env file details about your database and other services.

ynoth25's avatar

composer install was the first command I executed after I cloned the repository and that error popped up in the end.

I also tried to remake the .env file but still the same error. I checked the .giginore and /vendor folder was included.

Also I cant execute artisan properly because the error keeps popping up.

Sinnbeck's avatar

@ynoth25 Try removing the vendor dir and try again

rm -rf vendor && composer install
ynoth25's avatar

@automica At first I did created a repo using "git init --bare" command then cloned the repo.

and inside the cloned folder I did the laravel installation and pushed it to the repo.

But after I cloned it in other machine and executed composer install command, that was the time I get the error message.

automica's avatar

@ynoth25 ok. so on your new machine have you copied the .env.example to .env?

You'll need to ensure you aren't tracking the contents of vendor in your repo.

ynoth25's avatar

@automica I made a new .env file and copied the contents from the previous machine 's .env file.

I checked the .gitignore file and /vendor folder was included.

I was ashamed ahahahah, this is the time where I will introduce to my co developers the " Git " but this happened.

mirakmalsulton's avatar

Just cloning is not enough to run the application.

  1. clone the repository
  2. run composer
  3. set up .env
  4. start migrations
  5. setup directories permissions
  6. install npm packages
ynoth25's avatar

@mirakmalsulton I did steps 1- 4 and 6 actually, but the error still persisted.

also it' s not necessary to set directories permission since it' s in local and under development only.

Snapey's avatar

@automica

composer shouldn't care about .env files. What other steps are you running?

It doesn't, but composer.json includes at least one call to artisan in the post install scripts and this will fail if there is no app key

Please or to participate in this conversation.