webflorist/vuefactory

There is no license information available for the latest version (v1.0.1) of this package.

Build Vue Instances in PHP.

v1.0.1 2019-08-15 22:26 UTC

This package is not auto-updated.

Last update: 2024-04-19 14:53:06 UTC


README

PHP package to generate Vue-Apps

Description

This package provides functionality for building Vue-Apps in PHP.

Installation

  1. Require the package via composer: composer require webflorist/vuefactory

Configuration

No configuration is necessary.

Usage

Example

This PHP-code....

(new Webflorist\VueFactory\VueInstance('#app'))
    ->addComputed('computed_5','function () { return 2+3 })')
    ->addComputed('computed_8','function () { return 4+4 })')
    ->addData('string','value')
    ->addData('boolean_true',true)
    ->addData('boolean_false',false)
    ->addData('array',['item1','item2'])
    ->addData('object',(new \stdClass()))
    ->addMethod('say_hello','function () { alert("Hello!") })')
    ->addMethod('say_bye','function () { alert("Bye!") })')
    ->addPropsData('property1','value1')
    ->addPropsData('property2',true)
    ->addPropsData('property3',['item1', 'item2'])
    ->addWatcher('data1','value1')
    ->addWatcher('data2','value2')
    ->generate();

...results in the following JS-code:

new Vue({
    "el": "#app",
    "computed": {
        "computed_5": function() {
            return 2 + 3
        },
        "computed_8": function() {
            return 4 + 4
        }
    },
    "data": {
        "string": "value",
        "boolean_true": true,
        "boolean_false": false,
        "array": ["item1", "item2"],
        "object": {}
    },
    "methods": {
        "say_hello": function() {
            alert("Hello!")
        },
        "say_bye": function() {
            alert("Bye!")
        }
    },
    "propsData": {
        "property1": "value1",
        "property2": true,
        "property3": ["item1", "item2"]
    },
    "watch": {
        "data1": "value1",
        "data2": "value2"
    }
});