Closed skytower0098 closed 6 months ago
@skytower0098 Maybe need check to this thing - https://livewire.laravel.com/docs/installation#configuring-livewires-update-endpoint
@skytower0098 Maybe need check to this thing - https://livewire.laravel.com/docs/installation#configuring-livewires-update-endpoint
I am using Laravel 8 and Livewire 2
I have a Laravel project that has been modularized using the nwidart/laravel-modules package, and I’ve installed Livewire on it. However, when executing a component, I encountered the error:
The GET method is not supported for this route. Supported methods: POST.
I realized that I needed to install the mhmiton/laravel-modules-livewire package as well, so I could create components within the module path using a special artisan command. After that, the Livewire components worked correctly, but I can’t use Livewire events. Using $this->emit('event', $data) again triggers the error:
The GET method is not supported for this route. Supported methods: POST.
When I directly referenced the listener component’s path using $this->emitTo(\Modules\Products\Http\Livewire\ProductPriceHtml::class, 'event', $data), there was no error, but although the event was emitted, the listener did not respond to the event.
How can I use the $this->emitTo() event?
@skytower0098 Sorry, for the late response. I checked with Laravel 8 and Livewire 2. Everything is working for me. Could you share your demo script with me? So, I will be able to check more.
@mhmiton I realized that when creating a component, it should be placed inside a folder, and for two components to communicate with an event, their files must be alongside each other. By observing these points, Livewire requests will not be lost.
I'm getting this error when i tryed to create : php artisan module:make-livewire
Error
Class "Livewire\Features\SupportConsoleCommands\Commands\MakeCommand" not found
at vendor\mhmiton\laravel-modules-livewire\src\Traits\CommandHelper.php:156 152▕ } 153▕ 154▕ protected function isClassNameValid($name) 155▕ { ➜ 156▕ return (new \Livewire\Features\SupportConsoleCommands\Commands\MakeCommand())->isClassNameValid($name); 157▕ } 158▕ 159▕ protected function isReservedClassName($name) 160▕ {
1 vendor\mhmiton\laravel-modules-livewire\src\Traits\CommandHelper.php:132 Mhmiton\LaravelModulesLivewire\Commands\LivewireMakeCommand::isClassNameValid("AboutPage")
2 vendor\mhmiton\laravel-modules-livewire\src\Commands\LivewireMakeCommand.php:33 Mhmiton\LaravelModulesLivewire\Commands\LivewireMakeCommand::checkClassNameValid()
@saidrahmani2000 To resolve this issue, I suggest that you first check to see if the MakeCommand class actually exists and is placed in the correct path. Then, ensure that the namespace is correctly defined and finally, run the composer dump-autoload command to have Composer reload the class files. If the problem persists, you should check that all the necessary dependencies are installed and if necessary, run the composer install command.
When I use $this->emit('event', $data); I encounter the error “The GET method is not supported for this route. Supported methods: POST.” How should I use emit?