tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.91k stars 248 forks source link

ApiLoggerInterface Issue #601

Closed kuldeepBacancy closed 1 year ago

kuldeepBacancy commented 1 year ago

Hello,

Laravel version: "laravel/framework": "^6.18.35" I'm using the below 2 packages at the same time:

"awt/apilogger": "dev-master"
"tightenco/ziggy": "^1.0"

I've added @routes to some blade files which will be used to get all routes in the javascript files. Now I wanted to add some other packages and after installing/removing other packages I'm getting the error in pages where I've added @routes

I tried removing, installing, and updating the package. Also, checked some solutions and tried this one (Stackoverflow).

The error screenshot is attached. Can I get the solution for the same?

202667584-b01ab426-6544-4074-8a8f-ac24192ada55

bakerkretzmar commented 1 year ago

This doesn't look related to Ziggy. You said you tried uninstalling Ziggy, do you still see this error without @routes and without Ziggy installed?

kuldeepBacancy commented 1 year ago

No, After removing @routes the error is not showing.

But, I've added the same issue to the apilogger. And I'm sure that the error comes between these 2 packages only.

bakerkretzmar commented 1 year ago

Can you share a complete stack trace or any other debugging info? That screenshot looks like there's an error in your homenew.blade.php view, can you share that? With the information I have here this still doesn't seem related to Ziggy.

kuldeepBacancy commented 1 year ago

1) There is nothing different debugging for this. If I removed the Ziggy, APILogger package it'll work fine. But with these two packages, I'm not able to add any new packages. 2) It's only one type of the defined process before jquery and another js file that requires to get the routes, nothing else.

image

bakerkretzmar commented 1 year ago

@kuldeepBacancy I'd like to try to help debug this but I need more information. Can you please share a complete stack trace? Your original screenshot says the error is on line 19 of ApiLoggerInterface but it cuts off the code—what is on that line?

It looks like the apilogger package might be interacting with your routes in some weird way, are there any routes in your application where if you comment out the route completely, this error disappears and the page loads? If so can you share those route definitions?

It would be great if you could share a reproduction repo for this issue, or a link to your app if it's open source.

bakerkretzmar commented 1 year ago

The ApiLoggerInterface uses union types, which were added in PHP 8.0. Upgrading your PHP version should resolve this issue.