Giter Site home page Giter Site logo

unckleg / mezzio-vue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samsonasik/mezzio-vue

0.0 0.0 0.0 743 KB

Example Using Vue.js in Mezzio application

License: BSD 3-Clause "New" or "Revised" License

PHP 67.05% JavaScript 10.99% HTML 21.96%

mezzio-vue's Introduction

Example Using Vue.js in Mezzio application

ci build Code Coverage Downloads

Introduction

A Mezzio 3 Skeleton Application with Vue.js integration.

Features

  • SPA application with Vue Router with cached pages after visited.
  • Using server side template from Mezzio, compiled with Vue.compile() in Vue.js component's render().
  • Using Vuex for state management library, combo with sessionStorage on portfolio page.

Setup

1. Run composer create-project command:

composer create-project samsonasik/mezzio-vue
composer development-enable

2. Run PHP Development server

cd mezzio-vue
composer serve

3. Open web browser http://localhost:8080

Production

For deploy to production purpose, it has webpack.config.js in root directory that when we run webpack command, we can get public/js/dist/bundle.js after run it. If you don't have a webpack installed yet in your system, you can install nodejs and install webpack and webpack-cli:

sudo npm install -g webpack
sudo npm install -g webpack-cli

So, we can run:

webpack

Hash: 6ed53cca3add09d67d7f
Version: webpack 4.43.0
Time: 462ms
Built at: 06/22/2020 5:14:09 PM
                   Asset     Size  Chunks             Chunk Names
public/js/dist/bundle.js  2.9 KiB       0  [emitted]  main
Entrypoint main = public/js/dist/bundle.js
[0] ./public/js/app.js + 5 modules 5.08 KiB {0} [built]
    | ./public/js/app.js 1.61 KiB [built]
    | ./public/js/create-page.js 918 bytes [built]
    | ./public/js/about.js 388 bytes [built]
    | ./public/js/portfolio.js 1.68 KiB [built]
    | ./public/js/store.js 183 bytes [built]
    | ./public/js/portfolio-store-module.js 353 bytes [built]

After it generated, we can run the following commands to get production environment by default:

# ensure no left over file development config
rm config/development.config.php && rm config/autoload/development.local.php

# install with --no-dev
composer install --no-dev

# ensure no left over file cache before re-build cache
composer clear-config-cache

In default.phtml, we have a isDevelopment() view helper check to use js/app.js when on development, and use /js/dist/bundle.js on production when exists.

// src/App/templates/layout/default.phtml
$isDevelopment = $this->isDevelopment();

// ...
    ->prependFile(
        $isDevelopment
            ? '/js/app.js'
            : (
                // when after run webpack, allow to use bundled js
                // fallback to use /js/app.js when not
                file_exists('./public/js/dist/bundle.js')
                    ? '/js/dist/bundle.js'
                    : '/js/app.js'
            ),
        'module'
    )
// ...

that will automatically take care of that.

mezzio-vue's People

Contributors

samsonasik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.