VueJS 2.0 and Yii2

(Sganz) #1

Anyone using VueJS 2.0 as a front end to to a Yii2 application. Poked around and saw some VueJS 1.0 components, but didn’t see much for the newer 2.0.

Looking at doing something like VueJS or with Yii2.

Any integration tips, thoughts, etc would be most welcome.



(Alexander Makarov) #2

That’s just a JavaScript library so there should not be anything special about using it with Yii.

(Sganz) #3

Yeah, just wondering if anyone had done some tighter integration with Yii2. Doing thing that Yii already supports such as activeform stuff, things like that. Don’t think it would be too hard to make it work but checking to see if anyone had messed with it. I did seem some packages with mentions of Vuejs, but most look like just a way to include the JS code as part of the application, not tighter integration.

Thanks for the reply!


(Djchux) #4

I know it’s an old topic guys, but… anyone?

(Jacob Moen) #5

What I did just now - out of curiosity - was to search for ‘yii2 vue’ - and the search really didn’t turn up a whole lot, but it did turn up this:

Perhaps your search-foo is better than mine?

(Engr Arslanbutt) #6

(Jacob Moen) #7

That project is rather useless, IMO.

It uses Yii to register and publish Vue assets. Which is useless if you intend to fully replace the client with Vue.

If you’re not, then it is a start, although a very small one.

Better would be to use Yii for the backend and fully code the front in Vue.

For that you just need a guide somewhere in the Vue community that explains how to reach out to a backend (other than Node.js)

(Gzav) #8

Hello, I know that is not a recent topic but hey…here goes my point of view. It is just a question of workflow and also decision making on how much yii2 shall deal with the frontend. In order to be able to use the usual deployment workflow with git, i’ve used a vuejs source folder by using vuecli. I then changed the deployment file of vuejs in order to generate the final js files inside the yii2 frontend/web/js folder, I must say, with a mitigated result in terms of the workflow itself, mainly due to the limits of configuration of the vuejs deployment (but that was long ago…i didn’t try recently).

The main purpose was to have a specialized frontend team and a specialized backend team (mainly implementing yii2 rest endpoints) working together on the same time. That is a way to see things. However, vuejs can be implemented on several level/degrees in a very flexible way. Even jquery and vuejs can work together on the same screen. Based only on what i’ve tested I still haven’t found any pitfall (but I haven’t tested much). I have a good feeling about vuejs because the development environment makes it very easy/quick to develop something. Now, decisions must be taken to know which technology does what.

For example, routing and i18n can be managed fully by vuejs. So, you could decide, for example, to leave routing to yii2 and leave i18n management to vuejs. Or decide to really make yii2 a pure rest service and leave vuejs manage totally the frontend, including routing and i18n. Personally, i like that vision because, if you’re not a full stack dev, you can have 2 teams working on a same project. Having the vue source in the folder’s projects enable an easy versioning and the vue cli enables flexibility in deployment. The plus is that you have, consequently, an API ready to be consumed by anything else…a ionic or nativescript app for example.

(Auzadventure) #9

Hi, I’m on the Vue.js and Yii2 excos.

There are two ways to use Vue.js in your Yii2 application and I have used both methods.

  1. you have a complicated frontend need but your application is on Yii2. All you have to do is load the VueAsset and then create a vue.js object in the yii2 view. Yii2 is backend and will not mess up with your Vue.js.

In terms of teams, you can have an entire frontend team work exclusively on a Vue.js component and it won’t even touch your PHP.

  1. You want the power of Vue.js for a PWA. Then simply use Yii2 as a restful api that spits out restful. Use a library like axios to pull and put variables, while Yii2 will return the restful asJson.