Framework: Issue with component tags: "Unable to locate a class or view for component"

Created on 3 May 2020  路  5Comments  路  Source: laravel/framework


  • Laravel Version: 7.9.2
  • PHP Version: 7.4.3 (local), 7.3.17 (production)
  • Database Driver & Version:

Description:

I've ran into a weird issue today while using the new components from Laravel 7. I've created a WeeklyStats component (php artisan make:component WeeklyStats) and displayed it with
<x-weeklystats/>
in my local environment (Laravel Valet).
Everything works, loads, etc.

Problem appeared after deploying to my production server.
I kept getting the error "Unable to locate a class or view for component [weeklystats]. at [truncated]/vendor/laravel/framework/src/Illuminate/View/Compilers/ComponentTagCompiler.php:234)"

It only worked after i've used the same name as the view the component was loading
<x-weekly-stats/>

I've read the documentation and it states that "Blade component tags start with the string x- followed by the kebab case name of the component class". It's at least confusing because WeeklyStats kebab-cased is not weekly-stats.

Also, the other confusing part is why it worked locally in the first place. I did check after clearing all the cache and compiled views.

Most helpful comment

Could it be that your production server uses case sensitive file system while your local environment does not

All 5 comments

Hi @neamtua, when you run Str::kebab() on "WeeklyStats", it does in fact return "weekly-stats".

Capture

Why would it not be weekly-stats?

Before you close it, why does it work on Valet with <x-weeklystats>?

Could it be that your production server uses case sensitive file system while your local environment does not

Could it be that your production server uses case sensitive file system while your local environment does not

Sorry for commenting on a closed issue, but I just ran into this and this was indeed the case with a project I am working on. The client uses shared hosting and changing the component file name to only lower case worked on the production server.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

fideloper picture fideloper  路  3Comments

kerbylav picture kerbylav  路  3Comments

shopblocks picture shopblocks  路  3Comments