P
P
Pavel Bykov2020-03-02 14:08:43
Yii
Pavel Bykov, 2020-03-02 14:08:43

Is it possible to use models from Yii2 in this case?

Hello everyone, I want to use Yii2 + Vue.js and REST API with the concept of a single application page in the project, and then the question arose, when Yii2 itself will give the front, should it use models along the way and display the front with them, or would it be better if Yii2 will it just give the front, and the front itself, after loading, will request all the necessary data through the REST API?
Maybe someone knows ready-made repositories where the best approach for implementing the Yii2 + Vue.js + REST API stack is used?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-03-02
@mafof

Second option. Examples on github

A
Antonio Che Guevara, 2020-03-03
@iproman

There are probably 2 ways, as I do with angular, I think it's similar with vue.

  1. Yii2 returns the results using api and then work separately on the exterior of angular
  2. Embed angular in yii2 views, controllers, styles, etc.

Both there and there have their advantages, but I like option 1.
I created controllers, models with connections, tests with fixtures on a quick rest, and flew. If necessary, you override / create actions in addition to the default crud.
And you catch it all on the angular front, and sort out where what data is needed through services with requests to the backend.
Do not look for ready-made, try to write yourself. And you will understand how, what, what to cook with, and other nuances that you cannot catch when copying.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question