2017 © Pedro Peláez
 

yii2-extension yii2-vue

Vue.js manager component for yii2 web application

image

sablerom/yii2-vue

Vue.js manager component for yii2 web application

  • Friday, April 20, 2018
  • by sablerom
  • Repository
  • 2 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2 Vue.js Manager

This is the component for the yii2 app. This is the component for the application. It is a manager that allows you to conveniently manage settings and rendering of Vue.js., (*1)

Installation

The preferred way to install the vueManager is through composer., (*2)

Either run, (*3)

composer require sablesoft/yii2-vue

or add, (*4)

"sablesoft/yii2-vue": "*",

to the require section of your composer.json., (*5)

Then add vueManager in your app config:, (*6)

    ...
    'components' => [
        ...
        'vueManager'   => [
            'class'      => 'sablesoft\vue\VueManager',
            'delimiters' => [ '[[', ']]' ],  // specify custom for smarty
            'isDev'      => true              // false is default
        ],
        ...
    ],

How to Use

Just use vueManager::register method in your controller before rendering:, (*7)

    Yii::$app->vueManager->register([

        'type' => 'instance',  // is default, use 'component' type
                               // to register vue component

        // html element id (for vue class instance):
        'id' => 'buy-number',

        // vue class instance var name:
        'jsName'  => 'buyNumber',

        // path to your vue app sources ( see details below ):
        'sourcePath'    => '@yourAlias/path/to/vueApp/sources',

        // your vue app reactive data:
        'data' => [
           'routes'  => $yourRoutes,
           'flags'   => $someCustomFlags,
           'model'   => $yourModel->getAttributes(),
           ...
        ],

        // use jsExpression wrapper for short js
        // for long js use sourcePath ( see below ):
        'created' =>
            new JsExpression( "function() { console.log('Vue created!')}" ),

        // also you can use string value as path to your js:
        'computed' => '@yourAlias/path/to/computed.js',

        // for vue 'component' type:
        'props' => [...],
        'template' => '<li><span>...</span></li>'

    ]);

Vue Source Path

Use sorcePath for simple development and maintenance of complex vue apps and components. Just put all your js files for your vue app in one place. For example:, (*8)

    -app\
        ...
        views\

            // your controller views:
            hello\

                // source path to vue - @app/views/hello/index
                index\

                    // use 'components' directory for required components:
                    components\

                        // subdirectory name - is component tag
                        compA\
                            props.js
                            template.html
                        compB\
                            props.js
                            template.html
                         ...
                    // your vue app or component fields:
                    computed.js
                    methods.js
                    created.js

                // your action view:
                index.tpl

Source JS Syntax

JS files in your sourcePath must have a specific syntax. For js objects use this wrappers:, (*9)

    (function(){
        return {
            fieldA : 'fieldValue',
            fieldB : function(){...},
            ...
        }
    })();

For single functions as 'created', 'mounted' and similar you can use the usual syntax:, (*10)

    function created() {
        console.log('Vue app created!');
    }

And don't forget for vue chrome extension! :), (*11)

The Versions

20/04 2018

dev-master

9999999-dev

Vue.js manager component for yii2 web application

  Sources   Download

LGPL-3.0+

The Requires

  • yiisoft/yii2 *
  • bower-asset/vue 2.5.16
  • bower-asset/axios 0.18.0
  • bower-asset/lodash 3.5.0

 

by Roman Sable

yii2 vue vuejs vue.js lodash yii2-vue axios sablerom

20/04 2018

v1.0

1.0.0.0

Vue.js manager component for yii2 web application

  Sources   Download

LGPL-3.0+

The Requires

  • yiisoft/yii2 *
  • bower-asset/vue 2.5.16
  • bower-asset/axios 0.18.0
  • bower-asset/lodash 3.5.0

 

by Roman Sable

yii2 vue vuejs vue.js lodash yii2-vue axios sablerom