使用带有PHP索引的create-react-app [英] use create-react-app with php index

查看:92
本文介绍了使用带有PHP索引的create-react-app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用出色的create-react-app工具启动新的react项目,但我需要使用php服务应用,以便我可以获取一些动态数据和配置,并在启动之前对其进行反应.

i want to start new react project using great create-react-app tool, but i need to serve app using php to allow me to fetch some dynamic data and configuration and feed it to react before it starts.

我如何将create-react-app配置为服务器php?

how can i config create-react-app to server php ?

php有自己的内置服务器,所以也许我们可以用它来启动index.php

php have its own builtin server, so may be we can use it to launch index.php

php -S localhost:8000 ./public/index.php

有没有一种方法可以让webpack启动php内置服务器,并且仍然具有react-create-app附带的所有实时重载和功能?

is there a way to let webpack launch php built-in server and still have all live reload and features that comes with react-create-app ?

推荐答案

使用以下代码:

  1. 在命令行中打开您的应用程序文件夹.
  2. 用您的react config文件编写以下代码. (例如:development.config.js)

代码

webpack-dev-server --progress --inline --hot --port 8080 --config reactconfig/development.config.js

OR

npm start

这篇关于使用带有PHP索引的create-react-app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆