1

I have graphql API on Yii2.

Also, I working on a user interface written on ReactJS. I building bundle.js with all react files. The plan is to create SPA with yii2 API.

Where and how to add bundle.js in the yii2 framework? How to create an index page with such HTML?

<body>
  <div id="root"></div>
</body>

I want that react generate all content.

1
  • Do you know how yii works? At least take time to know the basics of the framework. Just find a view folder and put your code in the index file. Commented Aug 4, 2021 at 14:54

2 Answers 2

0

I am doing something similar right now. I am using Yii2 as RESTful API that serves HTTP request, and the separately, I use create-react-app to make a clean app and connect to the back end using HTTPS.

Sign up to request clarification or add additional context in comments.

Comments

0

One way to connect php Framework with Vuejs without another web-server nodejs is - webpack.

Configure in yii that there is only one controller and index: site/index. Configure all uri routes to that index: '/example' => 'site/index'. Configure that webpack build bundle js and add it to the layout. Configure uri for api, that vue going to use: '/v1/api' => 'api/index'.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.