• Stars
    star
    913
  • Rank 49,645 (Top 1.0 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A highly opinionated starter kit for building Single Page Applications with Laravel and Vue.js

Codecast's Single Page Application Starter Kit

Build Status

Cover

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.

Demo

The live demo can be found in https://spa.codecasts.rocks/.

Features

  1. 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
  2. Server side

Prerequisites

Make sure you have installed Node and Yarn (latest versions) as well as PHP 7 and MySQL.

Installation

Cloning

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"

Setup

  1. Client side - this is a Vue.js project created with vue-cli
    • With Terminal cd client && yarn && yarn run dev.
  2. 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 packages
      • touch database/database.sqlite to create an empty database file
      • cp .env.example .env to configure installation
      • php artisan key:generate to generate unique key for the project
      • php artisan jwt:secret to generate unique key for the project
      • php artisan migrate to create all the tables
      • php artisan db:seed to fill the tables with fake data
      • php artisan serve to serve application on localhost:8000

Usage

  1. Client side
  2. Server side
    • API endpoint is http://localhost:8000/api

Testing

Navigate to webservice folder and run the composer test script

$ composer test

Things worth mentioning

  1. 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;

  2. 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;

  3. 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;

  4. 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;

  5. 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.

Contributing

  1. Fork it!
  2. Create your feature branch from develop: git checkout -b feature/my-new-feature
  3. Write your code. Comment your code.
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin feature/my-new-feature
  6. Submit a pull request to develop branch :D

Credits

Fábio Vedovelli and dedicated contributors.

License

Licensed under the MIT license.

More Repositories

1

php-alpine

PHP APK Repository for Alpine Linux
Shell
482
star
2

laravel-jwt

Dead simple, plug and play JWT API Authentication for Laravel (5.4+)
PHP
234
star
3

codecasts

CODECASTS's source code
PHP
200
star
4

laravel

Laravel Skeleton By CODECASTS
PHP
49
star
5

rancher-deployer

Easily Upgrade Rancher Services
Shell
30
star
6

api-old

CODECASTS API
PHP
25
star
7

confee-web

CSS
17
star
8

confee-api

"Laravel Hardcore" video series API project
PHP
14
star
9

server-templates

PHP server templates for easy configuration
Nginx
10
star
10

github-pagination-parser

JavaScript
6
star
11

laravel-porn

6
star
12

restinga

Easily Create REST API Clients for your PHP Applications
PHP
6
star
13

serie-intro-quasar

Este é o código fonte gerado durante a série Introdução ao Quasar Framework
JavaScript
4
star
14

laravel-5.3-basico

Código fonte da série Laravel 5.3 Básico
PHP
4
star
15

serie-highcharts-vuejs

Código fonte da série Highcharts, Vue.js e Vuex.
Vue
4
star
16

modular

Aplicação Laravel 5 organizada em módulos
PHP
3
star
17

castor

PHP
3
star
18

app

CODECASTS V3 - APP
PHP
3
star
19

serie-intro-firebase

Código fonte da série Firebase.
JavaScript
2
star
20

slack-invite

slack.codecasts.rocks
PHP
2
star
21

disqus

PHP
2
star
22

presenter

PHP
1
star
23

laravel-api

Laravel API Skeleton
PHP
1
star
24

web

CSS
1
star
25

telegram-bot-php

1
star
26

ip-man

CLI IP Query Tool
1
star
27

vue-template

CSS
1
star
28

ambientum-cli

1
star
29

backup-confee

"Laravel Hardcore" video classes project.
PHP
1
star
30

support

CODECASTS Domain Tools, Support Package for our Laravel Skeleton
PHP
1
star
31

agendavel

Projeto da série "Laravel 5.1 Passo a Passo"
PHP
1
star
32

javascript-tips

JavaScript
1
star