Closed elrossco22 closed 1 week ago
We don't use the module with Livewire so far. Can you try to dig this down for any more verbose error messages or use Xdebug to debug? If you found a fix, a pull request would be very appreciated.
@amenk are you able to offer any help/guidance on the above. I've had a quick look however from what I can see Util::getParameterClassName($parameter) where $parameter->name ="routes" seems to return "Illuminate\Routing\RouteCollectionInterface" which then seems to traverse down through various functions within Application.php and Container.php before landing at the build() function and hitting an exception because it's not instantiable commentary for the function as below:
// If the type is not instantiable, the developer is attempting to resolve // an abstract type such as an Interface or Abstract Class and there is // no binding registered for the abstractions so we need to bail out.
You could try stackoverflow.com and / or provide a minimal reproducible example of the problem.
@amenk minimal reproducible example of the problem as below:
1.) Clean install of Laravel 2.) Install Livewire via Composer 3.) Install iMi-digital/laravel-trannsid via Composer 4.) Create a test LiveWire Component (php artisan make:livewire TestComponent) 5.) Embed the test component within a Blade file that will be called from one of your routes (@livewire('TestComponent')) 6.) Hit the relevant url endpoint for the controller than returns the view file which contains the livewire embed
@amenk a more helpful extract taken directly from my history
1.) composer create-project laravel/laravel=v9.4.0 test --prefer-dist
2.)composer require livewire/livewire
3.) composer require imi/laravel-transsid
4.) Edit config/app.php as per the imi/laravel-transsid instructions
5.) php artisan make:livewire ShowPosts
6.) edit resources/welcome/blade.php and add @livewire('show-posts')
anywhere on the page
7.) php artisan serve
8.) hit the laravel home route with tour browser and the error will appear
Thank you very much for documenting ... we might look into it when we have time; we do provide paid services though which could speed up things...
@amenk - could you please send me details r.e. paid service
@elrossco22 Please send me your contact to a.menk at imi.de
We will try to reproduce with Laravel 9
Reproduced on our system locally, trying to fix ...
Thanks for the update @amenk - look forward to further updates on progress
We have a possible fix and push it soon to a dev branch for testing.
@elrossco22 please try requiring the version dev-15-livewire
and see if it fixes your issue.
Hey @amenk - I've had a quick look and this partially fixes the problem. That is to say that a blade template that features a LiveWire component will now render however LiveWire itself does not work.
LiveWire essentially uses Ajax to update the page data as user interacts - such as clicking a button etc. These interactions/requests are being fired however they do not take into consideration the SID in the url - I can see from my developer tools that LiveWire is posting to /livewire/message/
without any SID url param so is still reliant on the cookie to identify the session.
Steps to reproduce as per our example above with the show-post
component would be:
1.) Edit resources/views/welcome.blade.php
and add @livewireScripts
above the closing </body>
tag
2.) Edit resources/views/welcome.blade.php
and add @livewire('show-posts')
in the main page div somewhere
3.) Edit resources/views/livewire/show-posts.blade.php
and add <button type="button" wire:click="callFunction" class="btn btn-danger">Click Me</button>
If you now visit the page and click the button you will get an error as we never created the function named callFunction
within out LivewWite Http Controller for ShowPosts. This is expectected! If you look in developer tools you will see that LiveWire is making it's Ajax request to /livewire/message/show-posts
which does not have SID on the url and therefore the session is dropped
We might need to patch https://github.com/livewire/livewire/blob/7d3a57b3193299cf1a0639a3935c696f4da2cf92/js/connection/index.js#L46 and rebuild the livewire.js (we are using v2.12.6)
Actually there must be a way to extend the livewire request or payload without patching livewire :-)
livewire has a message.sent hook, but does not have a message.prepare hook or something similar :-(
we try the approach via a custom header: https://stackoverflow.com/a/72270789/288568
@elrossco22 try the latest push on the branch, pay attention to the "Livewire" section in the readme,
Too include Session Id's use this script:
<script type="text/javascript">
document.addEventListener('livewire:load', function(event) {
Livewire.addHeaders({
'X-session': '{{ Session::getId() }}',
})
});
</script>
@amenk - I will test more extensively over the weekend but on a first pass this looks like it may be working :)
@elrossco22 Did you have a change to test thoroughly? If so, we would merge the change and publish a new version.
Will release a new version, thanks for reporting and the support
@elrossco22 please contact me
This works in livewire 3 and laravel 10 :+1:
Laravel horizon doesn't work, because they don't use the route() helper.
I'm trying to use this package (laravel-transsid) in conjunction with Livewire. I've followed the instructions in regards to adding the relevant service providers etc however when I call any of my Livewire components from within a blade template using the
@livewire("componentName")
syntax I get the below error[Target [Illuminate\Routing\RouteCollectionInterface] is not instantiable while building [Livewire\Redirector, iMi\LaravelTransSid\UrlGeneratorService].]
Any help would be much appreciated