What I want to create is a web application with Laravel Lumen and VueJS, where Laravel Lumen is used for an API and VueJS for a SPA. In the application I want an admin section, a small forum and the website. I want to reuse this concept in future projects where I can easily decide if I want a forum or admin section in the website, or possibility to expand easily like adding a shop.
My concept idea of structure
My idea was to make three separate vue instances of the different sections inside the Lumen project. A example of the directory structure would look as follow:
(lumen project)
├── app
├── node_modules
├── public
├── resources
│ ├── js
│ │ ├── admin
│ │ │ ├── components
│ │ │ ├── router
│ │ │ ├── store
│ │ │ ├── views
│ │ │ └── admin.js // where I create a vue instance
│ │ ├── forum
│ │ │ ├── components
│ │ │ ├── router
│ │ │ ├── store
│ │ │ ├── views
│ │ │ └── forum.js // where I create a vue instance
│ │ └── site
│ │ ├── components
│ │ ├── router
│ │ ├── store
│ │ ├── views
│ │ └── site.js // where I create a vue instance
│ ├── sass
│ │ ├── admin
│ │ ├── forum
│ │ └── site
│ └── views
├── routes
├── package.json
├── webpack.mix.js
...
With Laravel-mix the js/vue and sass files will be for each compiled to three separate files in the public folder:
const mix = require('laravel-mix');
require('laravel-mix-alias');
mix.js('resources/js/site/site.js', 'public/js')
.js('resources/js/admin/admin.js', 'public/js')
.js('resources/js/forum/forum.js', 'public/js')
.sass('resources/sass/site/site.scss', 'public/css')
.sass('resources/sass/admin/admin.scss', 'public/css')
.sass('resources/sass/forum/forum.scss', 'public/css')
.setPublicPath('public');
mix.alias({
'@': '/resources/js/site',
'@admin': '/resources/js/admin',
'@forum': '/resources/js/forum',
'~': '/resources/sass/site',
'~admin': '/resources/sass/admin',
'~forum': '/resources/sass/forum'
});
Then in the (laravel) Lumen Routes and controllers there will be decided which js, admin, site or forum, has to be included inside the Lumen View. So each section has there own Lumen View, like admin.blade.php
, site.blade.php
and forum.blade.php
. From there on the view will be generated inside Vue and Lumen will be used as API.
My question
I wonder if I'm going a good direction before I go further, is this a good practice? What could be better, or what should be totally different? I think that an other option would be separating everything totally and create separate repositories instead of one, but I want everything as one product. I'm looking for an answer which explains what would be best practice for my situation.