Production Environment "Unable to locate a class or view for component [layouts.base]."

I’m writing a Livewire app on a MacBook, and everything works perfectly. I go to deploy onto a production server today, setup by forge with default settings.

On the server, when trying to access my app or running php artisan view:cache, I get this error;

  InvalidArgumentException

  Unable to locate a class or view for component [layouts.base].

  at vendor/laravel/framework/src/Illuminate/View/Compilers/ComponentTagCompiler.php:274
    270▕         if ($viewFactory->exists($view = $this->guessViewName($component))) {
    271▕             return $view;
    272▕         }
    273▕
  ➜ 274▕         throw new InvalidArgumentException(
    275▕             "Unable to locate a class or view for component [{$component}]."
    276▕         );
    277▕     }
    278▕

The layout/component it claims to not exist, is infact present in the path it claims “doesn’t exist”. No idea what is causing this. There is very little in the way of solutions online about this so I would appreciate some help figuring it out.

I’m using exactly the method Caleb uses for his layouts in Surge, so I have absolutely no idea why this is happening. If your unfamiliar with the above, then please look below.

View\Components\Layouts\App.php

<?php

namespace App\View\Components\Layouts;

use Illuminate\View\Component;

class App extends Component
{
    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return view('layouts.app');
    }
}

resources\views\layouts\app.blade.php

<x-layouts.base>
    <!-- Content... -->
</x-layouts.base>

Probably related to the case sensitivity of your Production environment, so check your paths to see if you have made a typo.

I’m having the same issue on my Mac. Copied the exact code from the screencasts, must be a system environment issue.

Hey, @Creekmore108
Make sure to add x at the begging of the component name, (E.g: <x-auth/>)

Problem solved! I missed the fact that Livewire references the the Views directory under App not the Views under Resources. They in affect redirect to the layouts under Resources/views/layouts.
Solution

1 Like