Are there any good resources for integrating React into a Yii2 Project?

I’m looking to use React as part of my Yii 2 project to create an SPA. I’ve seen a number of extensions that deal with React in Yii, but I’m wondering if there are any tutorial resources explaining the best structure and implementation?

Usually that’s two separate applications. One is backend, Yii 2 REST. It is described in guide well. Another is React frontend that has no PHP at all.

@samdark

When you say it’s two separate applications, are you saying it’s impossible to do it as I’ve described, or simply not recommended?

You can place frontend/API part into a single project. That won’t make it a single application though.

If you’ve meant something else, please elaborate it.

I see yii router setup as the main thing that connects the two, other than maybe react app consuming api provided by yii. It wont be a single application, technically, but what you describe is definitely doable this way.

We use ReactJS in a few places in our app but we did not integrate ReactJS in the Yii project. There is no reason to integrate them. The front-end ReactJS app interoperates with the backend Yii app over REST API and Websocket.

@samdark @thefsb I pulled down the Basic app template and created a folder api, which holds my api module structure. I have repurposed the site/index action to be the page that serves the initial entry point for the SPA. From there it renders react, and makes calls to the api to pull down JSON.

@pkestefran Thanks, I’ve begun integrating ReactRouter, it looks exactly like what I need.