A highly opinionated Single Page Application starter kit built on top of Vue.js and Laravel.
This package contains two separate projects to act as a starting point for a Single Page Application: a Vue.js project (created with vue-cli + webpack template) and a Laravel 5.3 project.
They're not just freshly created projects but a fully working application that can be modified and expanded to become your own application.
The live demo can be found in https://spa.codecasts.rocks/.
- Client side
- Vue.js 2.0 project create with vue-cli + webpack template
- Centralized state management with Vuex
- Route management with Vue-router
- Authentication with JWT
- Keep user signed in using local stored info
- HTTP requests with Axios
- ESLint with AirBNB preset
- Pagination integrated with Laravel's LengthAwarePaginator
- Alerts and Confirmation Alerts provided by SweetAlert
- Server side
- Laravel 5.3
- Authentication with JWT
- Fractal
- Web service RESTful with Dingo (planned)
Make sure you have installed Node and Yarn (latest versions) as well as PHP 7 and MySQL.
These commands will download the repository and prepare it for you.
git clone --depth 1 -b master [email protected]:codecasts/spa-starter-kit.git
cd spa-starter-kit
rm -rf ./.git/
git init
git add --all
git commit -m "init"
- Client side - this is a Vue.js project created with vue-cli
- With Terminal
cd client && yarn && yarn run dev
.
- With Terminal
- Server side - this is a Laravel 5.3 project
- With Terminal:
- Navigate to webservice folder and then:
composer install
to install Laravel and third party packagestouch database/database.sqlite
to create an empty database filecp .env.example .env
to configure installationphp artisan key:generate
to generate unique key for the projectphp artisan jwt:secret
to generate unique key for the projectphp artisan migrate
to create all the tablesphp artisan db:seed
to fill the tables with fake dataphp artisan serve
to serve application on localhost:8000
- With Terminal:
- Client side
- Your application will be available on http://localhost:8080
- Server side
- API endpoint is http://localhost:8000/api
Navigate to webservice folder and run the composer test script
$ composer test
-
Error handling is done globally by making use of Axios' interceptors. But you can still .catch() errors within components to perform actions related to that scope. See /client/src/plugins/http.js;
-
The same way error messages lives in one single component (/client/src/modules/general/alerts.vue) and their visibility is controlled by a Vuex property. So to show/hide messages it is just a matter of dispaching a Vuex action from within any component;
-
The spinner displayed during server requests (see top right close to user indentification) is also controlled by a Vuex property. The procedure to show/hide it is the same as outlined in the item 2 above;
-
routes and Vuex modules live close to the modules they work for. Always look for routes.js and store.js inside a module directory. See /client/src/modules/categories;
-
Important: Laravel project found in the directory webservice was modified beyond adding routes and controllers. For instance: the webservice/app/Exceptions/Handler.php was modified from its original version to return all exceptions to the client, not only HttpExceptions. Other changes are also in place. So our recommendation is to always use this project to build your own, instead of copying controllers and routes to a new project.
- Fork it!
- Create your feature branch from develop:
git checkout -b feature/my-new-feature
- Write your code. Comment your code.
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature/my-new-feature
- Submit a pull request to develop branch :D
Fábio Vedovelli and dedicated contributors.
Licensed under the MIT license.