-1

I happened to open two instances of Laragon at the same time. After that php artisan migrate started throwing strange errores like "Interface not found" when that interface is actually there and was correctly imported. Tried different migrations and also throws random errors. I even tried with an old (already migrated) migration, copy pasted the code and it also didn't work. Always related to classes/interfaces not being found.

I've just noted that a simple test:

<?php

use App\Book;
use Illuminate\Database\Migrations\Migration;

class BookTest extends Migration
{
    public function up()
    {
        echo Book::HARDCOVER;

    }

}

doesn't work; it says: 'Class 'App\Book' not found' . The book class is there and was imported from phpstorm with a simple click. So, php artisan isn't finding any of my project classes.

I've just confirmed that tinker can't find the classes either.

Ok, I've just noticed that if I change in the book class the namespace to '\App\Models\Store' (where the file actually is) and I do from tinker something like \App\Models\Store\Book::HARDCOVER, then it actually works. The thing I don't get is why it's now (suddenly) needing me to update the name space to work...

Stephen H. Anderson
  • 978
  • 4
  • 18
  • 45
  • have you tried clearing cache (e.g.: `artisan cache:clear`) or regenerating autoloader (e.g.: `composer dump-autoload`)? – Kristian Jun 09 '22 at 01:10
  • yes, I have a clean.bat script that does these steps: php artisan down php artisan cache:clear php artisan optimize php artisan route:clear php artisan config:clear php artisan view:clear php artisan auth:clear-resets php artisan config:clear php artisan clear-compiled php artisan optimize php artisan up composer dump-autoload – Stephen H. Anderson Jun 09 '22 at 01:11
  • also, which laravel version is this? shouldn't it be `\App\Models\Book` rather than `\App\Book`? can you post the content of `app/Book.php`? maybe the namespace in that file is wrong? – Kristian Jun 09 '22 at 01:11
  • it's laravel 5.8, it was working (for years) suddenly it cant find anything. Even models that are there since 2017 – Stephen H. Anderson Jun 09 '22 at 01:11
  • @Kristian please see my last edit. – Stephen H. Anderson Jun 09 '22 at 01:26
  • its likely because you upgraded/updated to latest (or maybe just later) laravel version (e.g.: with `composer update`) – Kristian Jun 09 '22 at 01:30
  • I didn't do composer update. And this started happening suddenly today a few hours ago – Stephen H. Anderson Jun 09 '22 at 01:32

1 Answers1

0

Don't know how but my composer version was 2 so I had to downgrade to 1.10 and all works again.

Stephen H. Anderson
  • 978
  • 4
  • 18
  • 45