2017 © Pedro Peláez
 

project laravue

A Laravel template heavily inspired by the Vue.js webpack template.

image

prwlr/laravue

A Laravel template heavily inspired by the Vue.js webpack template.

  • Sunday, August 27, 2017
  • by prwlr
  • Repository
  • 2 Watchers
  • 4 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13789 Forks
  • 0 Open issues
  • 86 Versions
  • 0 % Grown

The README.md

Laravue

This is a Laravel template I use for my own projects., (*1)

How is it different from a clean Laravel installation ?

The most important change is that it removes all of Laravel Mix configuration and adds new webpack config files. I tried using Laravel Mix for some projects but it just didn't feel right. I didn't like how everything was configured, it took way too long to compile sometimes and I just felt like I had no control., (*2)

I took the new configuration files from the vue-webpack template and integrated them with Laravel. The workflow feels very nice and fast now., (*3)

I also rewrote all the views (even the ones generated by the Auth command) in Vue. The blade templates only define a mount point that maps automatically to a Vue component of the same name defined in the resources/assets/js/pages folder. I will explain more about this in a section below., (*4)

At the end there is a lot going on and it's really opinionated, but you can see all of the configuration files and change them if you need to. Or maybe you could just give it a try as it is and tell me what you think!, (*5)

How can I start a project using this ?

It's really easy to get up and running. Just follow these steps:, (*6)

  1. Start a project by running composer create-project --prefer-dist prwlr/laravue project-name.
  2. Go into your project directory and run yarn or npm install to install all dependencies.
  3. In your .env file there is a line that reads APP_URL=http://localhost. Change that variable to whatever your application url is. This is important for development since paths to assets will be constructed using this url. For example for the homestead default url it would look like APP_URL=http://homestead.app. If you app is running in a specific port just put it as it is, for example if your app is running on localhost at port 8000, just put APP_URL=http://localhost:8000.
  4. Now you may run yarn dev or npm run dev to start working on your project.

The command will try to open a browser automatically pointing to your project's url. Sometimes it won't be able to, for example when running with vagrant, so just open it manually., (*7)

You can also use the php artisan make:auth command which I modified to generate the same pages you would expect, but showcasing some Vue components instead., (*8)

About the Libraries

I'll try to list everything that has been included in the template., (*9)

  • Vue components can be written either using JSX syntax via .js files or using .vue files. I prefer the JSX syntax since I feel I have more control. It also feels more natural since I've been writing React for quite a while. If you want to use .vue files syntax, you will have to mount the components yourself. I will add automatic mounting of those later on.
  • SCSS is used to handle the base styles, variables, mixins and importing and overriding vendors.
  • Each Vue Component imports an .scssm file to handle its own styles. This file extension was defined by me to tell webpack to process this file with SCSS and CSS Modules. It's a nice combo since you have scoped selectors, and can also make use of your variables and mixins importing them from your sass folder.
  • Bulma has been imported instead of Bootstrap to handle some styles. Bulma It's more modern, it's completely independant from jQuery or Javascript in general, and you can easily integrate its components with Vue for example. You can remove it or just pull in the components you need since it's very modular. The views generated by the Auth command are using it though so just keep that in mind. There is also an example on how to override its variables.
  • Normalize.css is imported before any other css to handle some resets.
  • Animate.css was also included in the project. With this it's simple to add animations to some Bulma components or to your own stuff.

What tasks can I use ?

I'll just copy most of the descriptions from the Vuejs Webpack template since this is the template I merged with Laravel. If you want to know anything else about the tasks, about the folder structure or how to change or extend anything refer to their docs., (*10)

  • yarn dev || npm run dev: First-in-class development experience., (*11)

    • Start developing by going into your browser and hitting your APP_URL (It will try to open it automatically).
    • Vue preset to handle vue files written with JSX. This is the syntax I prefer since it's more powerful although a little bit more verbose.
    • Webpack + vue-loader for single file Vue components is also available.
    • Hot-reloading (It can't preserve the state though).
    • State preserving compilation error overlay.
    • Lint-on-save with ESLint.
    • Source maps.
  • yarn build || npm run build: Production ready build., (*12)

    • JavaScript minified with UglifyJS.
    • HTML minified with html-minifier.
    • CSS across all components extracted into a single file and minified with cssnano.
    • All static assets compiled with version hashes for efficient long-term caching, and a production base.blade.php is auto-generated with proper URLs to these generated assets.

There is a command for testing which is yarn test || npm run test, but it doesn't work for now. Still not sure how to handle testing for Vue Components using the JSX syntax. You can consider it WIP., (*13)

Configuration options

There is a folder called client_config which has some objects needed for the build and dev configurations. Most of them you don't need to worry about, but there are some that could be useful. For example you can set cssSourceMap to true to generate source maps in development. Is not activated by default because relative paths are "buggy" (A more detailed explanation can be found in a comment in the file). To know more about the options refer to the vuejs-templates webpack docs., (*14)

In the .env file you can also set a the DEV_POLLING to TRUE in order to enable polling in the webpack dev config. This is useful when running the project with Homestead for example., (*15)

You can also change the DEV_PORT variable in order to change the port in which express will be running (Express is used along with webpack to serve the assets)., (*16)

Notes

Laravel adds some useful stuff to a global Javascript variable called Laravel. I added some more stuff to it like the error bag and the old inputs. There is an utils folder where I created a file called laravel that just pulls in the global variable and exports it. Then in my Vue components I can import it to make calls to that variable a little bit cleaner., (*17)

If a view has an specific requirement for a php variable or something that it could get from Laravel, I have created some little blade files that I put in the resources/views/injectors folder that serve that purpose. They just add a script that attaches the new value to the Laravel global variable. You can then include this injector in the view that should use it. You can check some examples in the views that come by default or in the views generated by the Auth command., (*18)

Since I'm using Vue to handle all the content of the views, I've defined a new category of components called page components. You can find them in the resources/assets/js/pages folder. These components are used as the main entry points. There is a convention for connecting pages with views. All page components are created using folders with names written in Pascal Case and map automatically to a mount point or div with an id of the same value as the name of the folder but written in Kebab Case. For example resources/assets/js/pages/ExampleTest/index.js will mount automatically inside <div id="example-test"></div>., (*19)

So, anything else ?

Not really. I'd just want to thank you for giving it a try or at least reading through. If you have any feedback it'd be greatly appreciated. I bet a lot of things could be improved and I'm open to discussion, so open an issue, send a pull request or message me to gianluca.prwlr@gmail.com., (*20)

The Versions

27/08 2017

dev-master

9999999-dev

A Laravel template heavily inspired by the Vue.js webpack template.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

27/08 2017

v5.4.30

5.4.30.0

A Laravel template heavily inspired by the Vue.js webpack template.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

24/08 2017

dev-ft/set-up

dev-ft/set-up

A Laravel template heavily inspired by the Vue.js webpack template.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

14/08 2017

dev-develop

dev-develop

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

20/06 2017

v3.2.4

3.2.4.0

  Sources   Download

20/06 2017

v3.2.5

3.2.5.0

  Sources   Download

20/06 2017

v3.2.6

3.2.6.0

  Sources   Download

20/06 2017

v3.2.7

3.2.7.0

  Sources   Download

20/06 2017

v3.2.8

3.2.8.0

  Sources   Download

20/06 2017

v3.2.9

3.2.9.0

  Sources   Download

20/06 2017

v3.2.0-beta-2

3.2.0.0-beta2

  Sources   Download

20/06 2017

v3.2.1

3.2.1.0

  Sources   Download

20/06 2017

v3.2.10

3.2.10.0

  Sources   Download

20/06 2017

v3.2.11

3.2.11.0

  Sources   Download

20/06 2017

v3.2.12

3.2.12.0

  Sources   Download

20/06 2017

v3.2.13

3.2.13.0

  Sources   Download

20/06 2017

v3.2.14

3.2.14.0

  Sources   Download

20/06 2017

v3.2.3

3.2.3.0

  Sources   Download

20/06 2017

v3.1.4

3.1.4.0

  Sources   Download

20/06 2017

v3.1.5

3.1.5.0

  Sources   Download

20/06 2017

v3.1.6

3.1.6.0

  Sources   Download

20/06 2017

v3.1.7

3.1.7.0

  Sources   Download

20/06 2017

v3.1.8

3.1.8.0

  Sources   Download

20/06 2017

v3.1.9

3.1.9.0

  Sources   Download

20/06 2017

v3.2.0

3.2.0.0

  Sources   Download

20/06 2017

v3.2.0-beta-1

3.2.0.0-beta1

  Sources   Download

20/06 2017

v3.0.0-beta-2

3.0.0.0-beta2

  Sources   Download

20/06 2017

v3.0.0-rc-2

3.0.0.0-RC2

  Sources   Download

20/06 2017

v3.0.1

3.0.1.0

  Sources   Download

20/06 2017

v3.0.2

3.0.2.0

  Sources   Download

20/06 2017

v3.0.3

3.0.3.0

  Sources   Download

20/06 2017

v3.0.4

3.0.4.0

  Sources   Download

20/06 2017

v3.1.0

3.1.0.0

  Sources   Download

20/06 2017

v3.1.1

3.1.1.0

  Sources   Download

20/06 2017

v3.1.2

3.1.2.0

  Sources   Download

20/06 2017

v3.1.3

3.1.3.0

  Sources   Download

20/06 2017

v3.0.0

3.0.0.0

  Sources   Download

20/06 2017

3.0.x-dev

3.0.9999999.9999999-dev

  Sources   Download

11/05 2017

v5.4.23

5.4.23.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

28/04 2017

v5.4.21

5.4.21.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

20/04 2017

v5.4.19

5.4.19.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

17/03 2017

v5.4.16

5.4.16.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

15/03 2017

5.3.x-dev

5.3.9999999.9999999-dev

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

03/03 2017

v5.4.15

5.4.15.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

03/02 2017

v5.4.9

5.4.9.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

25/01 2017

v5.4.3

5.4.3.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

24/01 2017

v5.4.0

5.4.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

21/01 2017

v5.3.30

5.3.30.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

07/01 2017

dev-refactor

dev-refactor

A Laravel template heavily inspired by the Vue.js webpack template.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

03/10 2016

v5.3.16

5.3.16.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

20/09 2016

v5.3.10

5.3.10.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework vue.js

23/08 2016

v5.3.0

5.3.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

16/08 2016

5.2.x-dev

5.2.9999999.9999999-dev

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

27/04 2016

v5.2.31

5.2.31.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

15/04 2016

5.1.x-dev

5.1.9999999.9999999-dev

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

05/04 2016

v5.1.33

5.1.33.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

01/04 2016

v5.2.29

5.2.29.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

25/03 2016

v5.2.27

5.2.27.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

22/03 2016

v5.2.24

5.2.24.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

16/03 2016

v5.2.23

5.2.23.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

12/02 2016

v5.2.15

5.2.15.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

21/12 2015
30/08 2015

v5.1.11

5.1.11.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

01/07 2015

v5.1.4

5.1.4.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

23/06 2015

v5.1.3

5.1.3.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

11/06 2015

v5.1.1

5.1.1.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

09/06 2015

v5.1.0

5.1.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

08/06 2015

5.0.x-dev

5.0.9999999.9999999-dev

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

24/03 2015

v5.0.22

5.0.22.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

14/03 2015

v5.0.16

5.0.16.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

06/02 2015

v5.0.1

5.0.1.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

04/02 2015

v5.0.0

5.0.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel framework

09/11 2014

v4.2.11

4.2.11.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

01/06 2014

v4.2.0

4.2.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

15/04 2014

v4.1.27

4.1.27.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

19/01 2014

v4.1.18

4.1.18.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

11/12 2013

v4.1.0

4.1.0.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

14/10 2013

v4.0.9

4.0.9.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

07/09 2013

v4.0.7

4.0.7.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

07/09 2013

v4.0.8

4.0.8.0

The Laravel Framework.

  Sources   Download

MIT

The Requires

 

laravel framework

30/07 2013

v4.0.6

4.0.6.0

The Laravel Framework.

  Sources   Download

The Requires

 

laravel framework

10/06 2013

v4.0.5

4.0.5.0

The Laravel Framework.

  Sources   Download

The Requires

 

laravel framework

08/06 2013

v4.0.4

4.0.4.0

The Laravel Framework.

  Sources   Download

The Requires

 

laravel framework

28/05 2013

v4.0.0

4.0.0.0

  Sources   Download

The Requires

 

29/03 2013

v4.0.0-BETA4

4.0.0.0-beta4

  Sources   Download

The Requires

 

08/02 2013

v4.0.0-BETA3

4.0.0.0-beta3

  Sources   Download

The Requires