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.
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.
There are two ways to use Vue.js in your Yii2 application and I have used both methods.
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.
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.
We are using.
But our frontend team doesn’t know PHP and this case doesn’t require any dependence from a backend stack
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
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.
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