Class and View Stubs

Caleb and I had a discussion on allowing users the ability to customize their Class and/or View stubs, so I threw together a few PRs and they will be available in a future release.

The idea if you are consistently using Livewire to create the same type of functionality, like a modal or a datatable or something else, it would be nice to avoid copy pasting into every new component. Also, maybe you have some markup that you want included in every new component view. You can customize all of this stuff.

Here are a few videos I posted of the functionality:

Internally, it’s a fairly simple implementation (I tried to stick to the single file principle as much as possible, but ended up with 2 files. :sweat_smile:

There’s a StubCommand that will create a new stub that you can customize however you like which uses a StubParser to parse the input from the command. Once you’ve created your stubs, you can use them by adding --stub=modal to your make command. Or, if you created a default stub, it will be used automatically.

I hope everyone finds this helpful. Let me know if anyone has questions.


By the way, I haven’t submitted a PR to the docs yet to document this functionality. If anyone wants to contribute, this would be a pretty easy one to document.

PRs to docs repositories were how I got my start with open source, so if you’re thinking you want to get started but don’t know how, here’s a great chance.

1 Like