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.
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
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.
usual process for me to get started:
- create an empty remote repo
- check that out locally
- follow install instructions in laravel docs : https://laravel.com/docs/8.x/installation#your-first-laravel-project
- push files to remote repo.
composer shouldn't care about .env files. What other steps are you running?
@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.
@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.
@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.
Just cloning is not enough to run the application.
- clone the repository
- run composer
- set up .env
- start migrations
- setup directories permissions
- install npm packages
@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.
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.