Download the PHP package k3ssen/vue-bundle without Composer

On this page you can find all versions of the php package k3ssen/vue-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vue-bundle

VueBundle

A small SymfonyBundle that makes it easy to combine Twig and Vue.

Instead of using cumbersome data-* attributes or creating an API-endpoint for just about anything, this bundle lets you pass data to vue by calling {{ vue_data('someVariable', someObjectOrValue) }} in Twig. Form data can be used in Vue by using the v_model form-option. See Usage for more details.

Supported versions

Setup - quickstart

Install the bundle: composer require k3ssen/vue-bundle

You'll probably want to use setup VueJs with Symfony Encore (see Setup with Encore for details below), but for quickly trying out this bundle you can use the include-script below in your Twig code (replace the 3 with a 2 if you want to use version 2):

This will activate vue on the element with id="app", so you'll need an element that has this id set on it.

Example

If you use Symfony's MakerBundle to run php bin/console maker:controller Dashboard you should have an template/dashboard/index.html.twig file. You can replace the body block with the following:

This will result in a button that increments the counter once you click on it.

Setup with Encore

You can find elaborate information on Symfony's guides for installing Encore and Enabling Vue.

1. Install encore

composer require symfony/webpack-encore-bundle

2. Enable Vue.js

Enable Vue in webpack.config.js:

Tips:

  • You'll probably want to also uncomment the // enableSassLoader in webpack.config.js to use scss (which can be used in vue-components as well).
  • If you want to use Typescript, you should also uncomment //.enableTypeScriptLoader()

3. Install assets

Run yarn install followed by yarn dev. You may see errors that you need to install some additional packages. You can follow these instructions and re-run yarn dev until done.

Note: As of writing, Encore suggests installing vue@^2.5 with the appropriate loader. If you want to use Vue 3 you should remove or use different version constraints for vue packages.

4. Twig vue-javascript setup

The serverside data must be passed to vue, for which you can use the global window object. For example, you can add the following code in your base.html.twig:

The following things are relevant:

5. Create Vue instance

Finally, a vue-instance that uses this data must be created. Open your assets/app.js to add some code (see below).

Vue2

Vue3

Typescript
If you're using Typescript, you should edit app.ts instead. You can use similar code, but need to make some changes to make the compiler happy.

Usage

Using a global Vue-object

Complex Vue-logic should be written in Vue-components, but there are times when you want to do relatively simple Vue stuff inside Twig without any hassle.

By using a global object, this becomes fairly easy:

Passing server-side data to Vue

When you want to pass server-side data like an entity to Vue, you'd need something like this:

This works fine, but this has a bit too much boilerplate for simple scenario's where you only need to make data available.

To make this simple and more concise, this bundle adds these Twig functions:

Using v_model in forms

A typical case is that you have a form in which you want some Vue-logic.

This bundle adds a VueFormTypeExtension that provides a v_model option, which makes it really easy to have a v-model added to your form-field and make the data available to vue.

For example, your controller action could contain the following code to build a form:

Then in Twig you can use the name variable as Vue-data.

Other server-side data

If you have other data that you want to make available to Vue you can use the VueDataStorage service.

It ultimately boils down to an array inside this service that is converted to a json object that can be used by Vue.


All versions of vue-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
twig/twig Version >=1.40.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package k3ssen/vue-bundle contains the following files

Loading the files please wait ....