2

Folder structure:

Livewire
- Things
    - Addthing.php

Blade file

 @livewire('things.addthing')

is unable to locate it: Unable to find component: [things.addthing]

Without subdirectory, this works fine as:

Livewire
- Addthing.php

.

 @livewire('addthing')

How do I get Livewire components to work in a subdirectory?

1

3 Answers 3

6

It should work like this, did you also update your namespace to match the path?

For example:

namespace App\Http\Livewire\Things;
Sign up to request clarification or add additional context in comments.

1 Comment

I previously copied a whole component code into another (different directory/level). I had to change the namespace otherwise component cannot be found. Tyvm
2

Know this is an old question, but adding this here as ran into the same issue and it could help someone.

The issue I had was with the name spacing, so for example the namespace was:-

namespace App\Http\Livewire\SomeThing

Notice the capitalised T for Thing, so when we do this in the namespace we have to use an hyphen in the blade template to reference the space, so:-

@livewire('some-thing.component')

and same if we want to emit an event to this component:-

$emitTo('some-thing.component', 'event')

Simple thing but tripped me up

1 Comment

Thanks for this @ColinMD, I had a similar issue, locally livewire would be fine, but in prod my component <livewire:components.faqs></livewire:components.faqs> would not be found. The class was class FAQs so the component needed to become <livewire:components.f-a-qs></livewire:components.f-a-qs>
0

I referenced it as @livewire('things.addthings') in the blade and it worked maybe check your typo.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.