@include works @livewire not

Hi!

I created a component with Livewire artisan command.
It should implement a form.
I wanted to include at the end of one of my blade file.
if I want to render it with livewire @livewire( or <livewire: it is brakeing the page.
No any JavaSript error, nothing to see in logs.

I tired to sipmle @include( the same file it is rendering.
In the blade I have actulal a HELLO text in a div only.

Any idea, please?
br.
Gergely

Does your Livewire component have a single-level root element? Have you imported the Styles and Scripts? Are there any errors shown in the console?

Hi!
thanks for caring for my problem.
Yes I have a root div element.
Yes I have working livewire page, I wanted to include a livewire component.
It was no error everywhere.
What I investigated, the file owner and rightrs were wrong of the components. After i corrected it the problem was not solved.
Br.
Gergely

Can you post your code where you add the component?

It is a log form, but:
There is a working controller+blade “a” file livewire/subdir/a.blade.php, what is showing data. Is OK.
I intented do other LW component “b”, livewire/subdir2/b.blade.php to be a form, what I can insert into more places.

in the a.blade.php at the bottom of the existing file i tried to insert
livewire:subdir2.b/
it doesn’t do anythink but the page is stopped working and after this include row the html rendering stopped to. game over.
With this: it works, but i needed to move the controller’s things of “b” to the “a” too,.
@include(‘livewire.subdir2.b’)
Br.
Gergely

@include('livewire.subdir2.b') will only add the Blade View file without any Livewire functionality. You need to use @livewire('subdir2.b') or if you’re using Laravel 7 or higher you can use <livewire:subdir2.b/> to assist any further you’ll need to post some of your code.

Hi!
I have the issue again.
Now I ivestigated:
it seeam not to be loaded from autoload:
This works for me: livewire:mypayrolls/

app/Http/Livewire/Mypayrolls.php:class Mypayrolls extends Component
app/Http/Livewire/Mypayrolls.php: return view(‘livewire.payrolls.mypayrolls’,
bootstrap/cache/livewire-components.php: ‘mypayrolls’ => ‘App\Http\Livewire\Mypayrolls’,
resources/views/vendor/jetstream/components/welcome.blade.php: livewire:mypayrolls/
vendor/composer/autoload_classmap.php: ‘App\Http\Livewire\Mypayrolls’ => $baseDir . ‘/app/Http/Livewire/Mypayrolls.php’,
vendor/composer/autoload_static.php: ‘App\Http\Livewire\Mypayrolls’ => DIR . ‘/…/…’ . ‘/app/Http/Livewire/Mypayrolls.php’,

And this not: livewire:myapplies/

app/Http/Livewire/Myapplies.php:class Myapplies extends Component
app/Http/Livewire/Myapplies.php: public $permissionPrefix=‘myapplies_’;
app/Http/Livewire/Myapplies.php: return view(‘livewire.openjobs.myapplies’);

resources/views/vendor/jetstream/components/welcome.blade.php: {{ __(“applyforjob.myapplies”) }}
resources/views/vendor/jetstream/components/welcome.blade.php: livewire:myapplies/

resources/lang/hu/applyforjob.php: “myapplies” => ‘Beadott jelentkezéseim’
routes/web.php:use App\Http\Livewire\MyApplies;

only difference is what I can see
resources/views/vendor/jetstream/components/welcome.blade.php: livewire:mypayrolls/
vendor/composer/autoload_classmap.php: ‘App\Http\Livewire\Mypayrolls’ => $baseDir .

This is missing for the failed component.
How can I pass new contorller to this section?
Thanks
gergely

This file was hacked by me:
bootstrap/cache/livewire-components.php 542/542 100%

<?php return array ( ..... 'mypayrolls' => 'App\\Http\\Livewire\\Mypayrolls', ---->>>>> 'myapplies' => 'App\\Http\\Livewire\\Myapplies', 'open-jobs' => 'App\\Http\\Livewire\\OpenJobs', ); then started to work. When and how is this file generated, please? Br. Gergely

You shouldn’t need to touch the autoload.php file and you certainly shouldn’t touch any of the cache files that Laravel generates. Try running php artisan view:clear to fix your cache.

Your code is a bit hard to read. You can add formatted code to the forums if you place it between three backticks ``` you’ll see it in the live view on the right as you’re typing.

From what I can gather it appears that you are using different namespaces for your Livewire components and your view files. For example, you have <livewire:myapplies/> but your view is openjobs/myapplies.blade.php is that correct?

If you have a component inside of a sub-folder with its own namespace, you must use a dot prefixed with the namespace. For example:
<livewire:openjobs.myapplies/>