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

Chris1904's avatar

Issues when cloning a project from Github

Hi everyone,

I currently store one of my projects on Github for version control. Now, when I clone this repo on a new machine, I would do the following:

  1. git clone ...
  2. edit the .env files
  3. composer install
  4. php artisan migrate

The issue starts occurring when I run composer install. It seems that when I run the command, the service providers (maybe even Controllers?) are being loaded which include some database queries. Clearly, this would result in an error, because the database has yet to be migrated.

Why is that when I run composer install the service providers get loaded? Why aren't just solely the dependencies get installed?

composer install

...

> php artisan optimize


  [Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'clooud2.settings
  ' doesn't exist (SQL: select `attributes` from `settings` where `name` = me
  dia limit 1)



  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'clooud2.settings
  ' doesn't exist



  [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'clooud2.settings
  ' doesn't exist


Script php artisan optimize handling the post-update-cmd event returned with error code 1

How can I work around this issue or what could a valid solution be?

Same goes for php artisan migrate. It seems that the same error gets thrown saying the settings table does not exist. Why are any service providers here loaded as well, instead of just running the migrations and the related config files?

Thanks so much for any help,

Chris

0 likes
1 reply
nolros's avatar

@CHRIS1904 sounds like your migration table is corrupt or you have drop issue with settings. Im assuming this is not production? If so you could do the following:

  1. try reset 

  php artisan migrate:reset
  // If it wont allow you to reset because of the  settings table then

  2. delete the migration table then run 

  php artisan migrate:install 

  3. if this works then I tend 
    
     php artisan migrate:reset (rollback all)
     // 3.1 delete migration table again
     composer dumpautoload
     php artisan config:clear
     php artisan migrate:install 
    // (btw php artisan migrate will create teh DB if it doesnt exist but I prefer to go through the steps)
     php artisan migrate

    4. If the problem persists then you have an issue in one of your migrations in which case fix and repeat the above until problem resolved

1 like

Please or to participate in this conversation.