Search code examples
phplaravellaravel-blade

Laravel Component Recognized in One file but Not Another


I've solved this issue, But I'm EXTREMELY confused on what's going on here, and would like someone to explain it to me for future reference.

So I have a Laravel 10 Project and my first route is a welcome page

Route::get('/', function () { return view('welcome'); })->name('welcome');

I made a Blade Component that's just a static menu. I generated it, Copy/pasted the existing menu, made a slight edit, replaced block with <x-header-menu /> and it worked fine in the welcome view.

enter image description here

I then made a new php file from scratch, and in this view, The blade component was Not Recognized. When I loaded the page, It didn't work. WHAT? Code was copy/pasted from the welcome page. This view was inside a folder So

Views/welcome.blade.php
Vs
Views/info/info_page_1.blade.php

But I have other pages inside folders that use a different component that work fine. So I'm SUPER confused as to what's happening here. (Using PhpStorm IDE btw)

enter image description here

Now The Weirdest thing here though, Is when I deleted info_page_1.blade.php, copy/pasted the Welcome.blade.php to info_page_1.blade.php, Then copy/pasted old info_page_1.blade.php code, It worked.

So... WHAT HAPPENED HERE? Why could the Blade Component not be found with a new file but could be found with a copy/pasted already working file, In the same location with the same name?


Solution

  • Found the answer immediately as I switched back...

    Name your file

    info_page_1.blade.php
    

    instead of

    info_page_1.php