skip to Main Content

I have created a straight up laravel project, just the boilerplate. When I use the sail guide (https://laravel.com/docs/9.x/sail#installation), I run composer require laravel/sail –dev and that runs fine, but when I do php artisan sail:install I get this error:

ErrorException 

  file_get_contents(/home/michaelb/Desktop/scouting/.env): Failed to open stream: No such file or directory

  at vendor/laravel/sail/src/Console/InstallCommand.php:125
    121▕      * @return void
    122▕      */
    123▕     protected function replaceEnvVariables(array $services)
    124▕     {
  ➜ 125▕         $environment = file_get_contents($this->laravel->basePath('.env'));
    126▕ 
    127▕         if (in_array('pgsql', $services)) {
    128▕             $environment = str_replace('DB_CONNECTION=mysql', "DB_CONNECTION=pgsql", $environment);
    129▕             $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment);

      +15 vendor frames 
  16  artisan:37
      IlluminateFoundationConsoleKernel::handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))

This is after selecting that I want pgsql database. What do I do to fix this?

2

Answers


  1. Did you run the command below in your project folder?

    sail up
    

    This will create and make ready the project for you using docker.

    Main error is that you do not have .env file in your project. You can copy and paste .env.example to .env file. It will solve your problem.

    You have to run composer install command in your container. Not in you local machine. However, I think you missed few steps because laravel should create .env file for you.

    Login or Signup to reply.
  2. You got an error because you have missing vendor folder in your project, You need /vendor because all your packages are there, including all the classes Laravel uses. The vendor directory contains your Composer dependencies.

    Your problem can be resolved after following this step. you can try it:

    composer update --no-scripts 
    composer update
    

    With this command, you will re-create the vendor folder in your project and after that your project will start working normally.

    this answeare is given at this link

    https://stackoverflow.com/questions/54033140/failed-opening-autoload-php-in-laravel-5 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search