Skip to content

[4.x] Prevent calling Inertia before it's installed#1376

Merged
taylorotwell merged 1 commit intolaravel:4.xfrom
jrd-lewis:inertia-bug-fix
Sep 18, 2023
Merged

[4.x] Prevent calling Inertia before it's installed#1376
taylorotwell merged 1 commit intolaravel:4.xfrom
jrd-lewis:inertia-bug-fix

Conversation

@jrd-lewis
Copy link
Contributor

When you pull in Jetstream into a fresh Laravel project manually and try accessing it in a browser before running the php artisan jetstream:install command, it will have the error that "Class 'Inertia\Inertia' not found" from the ShareInertiaData middleware. To prevent that, I added a check to ensure the class is present before calling the bootInertia method in the ServiceProvider.

image

@jrd-lewis jrd-lewis changed the title Prevent calling Inertia before it's installed [4.x] Prevent calling Inertia before it's installed Sep 16, 2023
@driesvints
Copy link
Member

I don't think this is necessary? Why would you try to run the app before running the install command?

@jrd-lewis
Copy link
Contributor Author

jrd-lewis commented Sep 17, 2023

It would bring consistency with line 40 of this service provider where it ensures Livewire is installed before registering the Livewire components.

One use case is someone is doing TDD for their project and pulls in Jetstream to handle authentication redirections for guest users but doesn't run the install command immediately. In that case, it would bring up the error about the Inertia class not being found as it does in the browser.

@taylorotwell taylorotwell merged commit 83056da into laravel:4.x Sep 18, 2023
@jrd-lewis jrd-lewis deleted the inertia-bug-fix branch September 18, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants