Z
Z
Zhenya Starikov2020-07-07 20:04:05
Yii
Zhenya Starikov, 2020-07-07 20:04:05

How to link between Yii2 and ReactJS?

There is a question that will seem silly to you. I created an API in Yii2 (basic), which allows you to get the necessary data from the database in json format. Yii2 runs on a local server. Now I want to create, in fact, a React interface and use Ajax requests to access this data.
What do I need to do? Create create-react-app in the root folder of the project, and somehow tell yii about this project? Or is it done in some other way? Please answer, I'm new to this.
And yet, is the application necessarily an SPA, or maybe an MPA?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim, 2020-07-07
@evster-coder

If you have created an API, then why do you need to combine these two applications in one? Access Yii2 API from React JS. Authenticate by token. As a result, you will have two independent applications that will work over the HTTP protocol. I wouldn't combine them.

A
Alex Glebov, 2020-07-07
@SkiperX

2 different projects, communication via rest api

G
GloryLight, 2021-01-05
@GloryLight

Try ReactYii2Essentials , it will add all the familiar components from Yii2 to React and make it easier to migrate to it. And Yii2 will continue to be in the form of an API server with goodies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question