close

[Solved] Laravel “Unable to locate a class or view for component” in production environment

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Laravel “Unable to locate a class or view for component” in production environment in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Laravel “Unable to locate a class or view for component” in production environment Error Occurs?

Today I get the following error Laravel “Unable to locate a class or view for component” in production environment in php.

How To Solve Laravel “Unable to locate a class or view for component” in production environment Error ?

  1. How To Solve Laravel “Unable to locate a class or view for component” in production environment Error ?

    To Solve Laravel “Unable to locate a class or view for component” in production environment Error In my case, I had created a component inside another folder, for better organization sake:

  2. Laravel “Unable to locate a class or view for component” in production environment

    To Solve Laravel “Unable to locate a class or view for component” in production environment Error In my case, I had created a component inside another folder, for better organization sake:

Solution 1

I was facing the same issue and I fixed it by cross-checking my folder name.

Please note that the folder name should be components and not component.

In case you are following the convention, one more thing is that if you have a file at

views/admin/side-menu/side.blade.php

You can call your Component as:

<x-admin.side-menu.side></x-admin.side-menu.side>

Solution 2

I had the same problem. Thanks to your question, I could find out how to solve it 😀

In my case, I had created a component inside another folder, for better organization sake:

$ php artisan make:component Tutorial/channelName/Alert

So it created the view component inside the following directory:

views/components/tutorial/channel-name/alert.blade.php

Now, to call your component you do it this way:

<x-tutorial.channelName.alert />

That’s pretty much it.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment