tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.83k stars 247 forks source link

Class "Tightenco\Ziggy\Ziggy" Not Found After Upgrading to Laravel 11 #731

Closed OmarBouziane closed 5 months ago

OmarBouziane commented 5 months ago

Ziggy version

2.0.4

Laravel version

11.0.6

Description

Hello,

I recently attempted to upgrade my application to Laravel 11 and encountered a significant issue. Specifically, the "Tightenco\Ziggy\Ziggy" class could not be found, causing my application to break. This issue arises in the context of an application that utilizes Laravel with Inertia.js and Vue.js.

Has anyone else encountered this issue, or does anyone have suggestions on how to resolve it? Any assistance would be greatly appreciated as I am currently unable to proceed with the Laravel 11 upgrade due to this problem.

Thank you!

Ziggy call and context

E.g.:

<Link :href="route('profile.show')">
<Link :href="route('dashboard')">

and everywhere I use the route helper

Ziggy configuration

HandleInertiaRequests

use Tightenco\Ziggy\Ziggy;

'ziggy' => function () use ($request) {
    return array_merge((new Ziggy)->toArray(), [
        'location' => $request->url(),
    ]);
},

app.js

import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';

// Usage with Vue
.use(ZiggyVue)

In app.blade.php, I include the @routes.

Route definition

Route::get('/profile', [ProfileController::class, 'show'])->name('profile.show');
bakerkretzmar commented 5 months ago

As noted in the upgrade guide, Ziggy's PHP namespace changed from Tightenco to just Tighten in v2. It would be helpful if you included more context about the specific error you're seeing (including a stack trace) and where it's coming from, but if you're using that class anywhere make sure to update your imports.

ANDRU19 commented 5 months ago

It's a cache issue. All you need is to restart your web server and clear the application cache.