Hello, I am trying to build a laravel project. I install fresh laravel with composer but when I delete the .env file it gives an error. All I want is to create the .env file after installation. I mean I want to take the input from the user and then store them in the .env file. But the project won’t run without a .env file.
Please help me solve the problem.
Most likely you are getting the error for missing APP_KEY config. All application config comes from the config files in the config/
folder. The application key is in the config/app.php
file. Open the file and search for the following line.
'key' => env('APP_KEY'),
Now add a second parameter there for a default application key like below.
'key' => env('APP_KEY', 'siwosp6b3izlfr7thexibrOb2f0Docr6'),
Generate a random string and add it there. Please remember, always use .env file and use artisan to generate the app key.
php artisan key:generate