MyLibrary's avatar

Best structure for Vue.js SPA and Laravel together?

Hey guys, I'm starting to move massive parts of my current site to Vue.js. The app.js file located at the assets/js folder, and I wonder how should I organize my files over there? Any best practice or a good idea?

I've some pages (Like Gallery, Event, Article) and each page composed of components, of course, I'm using Vuex and routing.

Will be happy if someone can share a good advice?

0 likes
2 replies
wilburpowery's avatar
Level 23

Hey @MyLibrary I developed a few months ago a full SPA with Vue.js and Laravel. I'll share you the repo.

https://github.com/wilburpowery/cashflow-assistant/tree/master/resources/assets/js

But this is the basic structure I always follow when working with Laravel and Vue.js with SPA's. My Structure

  • I keep all my components in the components folder. (Componente would be like a reactive html input, etc. )
  • All the pages of my applications (like dashboard, settings, profile, etc.) are in a pages folder.
  • Inside a router folder I have a routes.js file that contains all the routes for my application and a index.js file that exports a new router instance.

All other info you can keep by checking out the repo. Hope it helps. ?

7 likes

Please or to participate in this conversation.