3 weeks ago

Laravel claims a model is not found (but it definitely exists)

Posted 3 weeks ago by JacobFHolland

I am currently following the TDD birdbox videos and am experiencing an issue with Laravel claiming that the Project model cannot be found. I am on the very start of it doing my first test. I have confirmed up until the part where you need to make the Model, and everything functions as it should in the video until then.


namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class ProjectsTest extends TestCase
    use WithFaker, RefreshDatabase;

    /** @test */
    public function user_can_create_a_project()
        //Disables Exception Handling so routes can be ignored temporarily

        //Create an array of fields to check in the table
        $attributes = [
            'title'=> $this->faker->sentence,
            'description' => $this->faker->paragraph

        //Make POST request to route

        //Assert Database has the fields in the table


use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');

Route::post('/projects', function(){
	App\Project::create(request(['title', 'description']));



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Project extends Model
    use HasFactory;


And I am getting the error in PHPUnit

There was 1 error:

1) Tests\Feature\ProjectsTest::user_can_create_a_project
Error: Class 'App\Project' not found

I can very clearly see that Project.php is in my app\Models folder as created by the command line. Any ideas?

Please sign in or create an account to participate in this conversation.