VueJS 2.0 and Yii2

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 Aurelia.io with Yii2.

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

Thanks

Sandy

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

1 Like

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!

Sandy

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

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:

https://bitbucket.org/innologica/yii2-vue/src

Perhaps your search-foo is better than mine?

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)

2 Likes

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.

2 Likes

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.
1 Like

I have created a Yii2 basic template with VueJs Framework. You can use it

1 Like

Worth posting about it at https://yiifeed.com/. Please suggest a short mention. Thanks!

Yeah not bad. I think it could do with some documentation. Will try to help.

I have created this library to simplify embedding Vue.js into Yii2 without using webpack or similar:

1 Like

I will definitely post at the right time. Thank you for your efforts

We are using.
But our frontend team doesn’t know PHP and this case doesn’t require any dependence from a backend stack :slight_smile:
Use REST or other APIs and all developers will be happy

For example
The backend’s team is planing rewrite a few functional for performance by Golang
No problem, frontend will not know about it

The frontend’s team is planing rewrite a few pages or even create a new site
No problem, backend will not know about it

Or we will have a mobile application.
Ok, we are ready, we have API!

For some cases i recomend use a lightweight UI framework, as Riot.js
I have the experience of integration it with Yii2. It’s easy and usefull

But i strong don’t recomend this way for React, Vue or Angular

“Fullstack is dead” for heavy UI frameworks

It depends. If you are building a public website, React, Vue or Angular have some issues mainly related to SEO; so if you need to apply few interactions with the users, this technique could be the right way.

Not all projects need heavy UI frameworks.

Of course it depends!

Classical rendering HTML on backend is live and will be live
Many admin dashboards don’t require SPA and therefore can be written very fast by backend developers.
And many web sites too.
Simple JS plus some “jQuery” will be enough