How to access using php a json file located in the src folder in ReactJS
my data.json file in my Project
After building I can't access to the data.json file
The files look like this build folder
How to access using php a json file located in the src folder in ReactJS
my data.json file in my Project
After building I can't access to the data.json file
The files look like this build folder
Generally speaking, you don't. The src folder contains the source code for the React app. It isn't something that should be directly used in production.
If you are using Webpack to build your production version then, as per this answer you can use the CopyWebpackPlugin plugin to copy the JSON file to your build directory and deploy it with the rest of the application.
That should give you a predictable file path (if the PHP is on the same system as the server for the React frontend) or URL (otherwise) that you can request with file_get_contents
and then parse with json_decode
.