Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jakub003's avatar

Livewire centered project folder structure suggestions?

I am looking for advice on how to set up a laravel livewire project, that would use the livewire full page renders. I went through all the full-page livewire posts on laracasts, and there wasn't much discussion. Couldn't really find any good discussion on this on Google or Reddit either.

Laravel Daily had a video a while back with a project example that used livewire only https://www.youtube.com/watch?v=xY0O2tSO8v0

So with the recent announcement of Livewire v3 coming out, I want to start my next project and try out this approach. Especially since the new v3 will allow for that SPA feel when using the full-page components.

Is this something anyone has tried to implement themselves?

So here is my shot at a potential setup, would love to get some feedback and pointers on how to improve this.

Organizing By Pages

I was thinking of keeping things grouped together based on pages. To keep all the components that would appear on any given page, inside the same folder. So if you go on the page site.com/app/dashboard you know all the files for all the stuff you find there in /livewire/app/dashboard

// app pages
/livewire/app/dashboard/view
/livewire/app/dashboard/active-tasks-table

/livewire/app/projects/view
/livewire/app/projects/list-of-projects-table


// guest pages
/livewire/guest/home/view
/livewire/guest/home/newsletter-cta-form

/livewire/guest/about-us/view

/livewire/guest/contact-us/view
/livewire/guest/contact-us/email-contact-form

Laravel Daily Video

The design I have seen in the video series I something l like this

With this approach if this is the better one. Should I be going more nested?

// nested
/livewire/pages/guest/Home/HomeIndex
/livewire/pages/guest/AboutUs/AboutUsIndex

/livewire/pages/app/Dashboard/DashboardIndex
/livewire/pages/app/Projects/ProjectsIndex
/livewire/pages/app/Projects/ProjectMilestonesView
/livewire/pages/app/Projects/ProjectSprintsView
/livewire/pages/app/Projects/ProjectTasksView


// not nested
/livewire/pages/guest/HomeIndex
/livewire/pages/guest/AboutUsIndex

/livewire/pages/app/DashboardIndex
/livewire/pages/app/ProjectsIndex
/livewire/pages/app/ProjectMilestonesView
/livewire/pages/app/ProjectSprintsView
/livewire/pages/app/ProjectTasksView
0 likes
8 replies
webrobert's avatar

Hi @jakub003,

I've done livewire both ways. And it really depends for me on the size of the project.

Here is one now. Please forgive the mess, I haven't refactored yet to clean things up...

Http\Livewire\

AssignmentIndex.php
BusinessIndex.php
BusinessShow.php
DealCalculatorShow.php
ListingShow.php
ListingsIndex.php
PeopleLookup.php
ProjectIndex.php
ProjectShow.php
ReplyIndex.php
ReplyModal.php
ReplyShow.php
Test.php
TodoItemAdd.php
TodoItemShow.php
TodoList.php // probably will rename to TodoListIndex.php
TodoSet.php // probably will rename TodoSetIndex.php but I dont quite like that either.
ValuationCalculator.php
ValuationShow.php
// of course these could go into a traits folder...
WithAuthRedirects.php
WithMoney.php
WithMorphables.php
WithSorting.php
WithStripTags.php

The thing I don't like about nesting them is the duplicate naming. Reply/ReplyIndex.php

But a sure way to get confused is to Reply/Index.php // definitely don't do this

So I may go in and nest them anyway, Mainly by model.

For me that happens faster in the views because I tend to have more views than "Controllers".

...Views

api
auth
components
financial-statements
layouts
legal
profile
todo /* a look at when it merited creating directory... */
	_items.blade.php
	_items-header.blade.php
	_set-todo-list.blade.php
	add.blade.php
	item.blade.php
	list.blade.php
	set.blade.php
valuation-report
vendor
_sort-icon.blade.php
about.blade.php
assignment-index.blade.php
business-create.blade.php
business-index.blade.php
business-show.blade.php
buying-criteria.blade.php
contact.blade.php
dashboard.blade.php
deal-calculator.blade.php
home.blade.php
listing-show.blade.php
listings-index.blade.php
navigation-menu.blade.php
news.blade.php
people-lookup.blade.php
process.blade.php
project-index.blade.php
project-show.blade.php
reply-index.blade.php
reply-modal.blade.php
reply-show.blade.php
test.blade.php
valuation-calculator.blade.php
valuation-show.blade.php
1 like
Jakub003's avatar

@webrobert

This is great! Thank you for the detailed response. :)

Do you use anything like Actions to organize stuff as well in your projects? I am not trying to go too deep down the rabbit hole of abstractions but trying to keep things somewhat organized.

Still trying to decide how to use Action or Service Providers

Jakub003's avatar

@webrobert

I wish there was like a highly opinionated blog post breaking down how to plan a livewire-focused project, with some limited abstractions

Have you ever come across anything like this? I think that's what I might work on is a cookie cutter blue print to try follow as a good foundation.

I find myself doing a new approach with each new laravel project lol

webrobert's avatar

@Jakub003,

I am still trying to better implement actions/jobs. Source dive Jetstream for ideas. Taylor uses actions in the livewire components.

I don't have a hard and fast rule. Obviously there are probably/maybe some pages that don't need a "Livewire Controller." I have plenty that don't... meanwhile, I just checked.

Here are the "Normal Controllers" from the same project...

Controllers
	DownloadValuationController.php
	LegalController.php
1 like
Jakub003's avatar

@webrobert I think with preparation for the new livewire V3 it's best to go with everything. So we can use that fancy SPA approach on the site and still be fully SEO friendly haha

Jakub003's avatar

@webrobert Do you use any partials or anything like that? Or just livewire components + regular blade components

webrobert's avatar

@Jakub003,

I do have some partials. I like to keep them with the related model, if there is one (see the todo directory in my first reply). All the blade files there that start with an underscore are _partials.

Please or to participate in this conversation.