React on PHP environment
Author: Emin Muhammadi (https://muemin.me). You can contact here for ideas and suggestions.
In this article, I am going to walk you through setting up a PHP backend server for a React Application.
Before starting
React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. We don’t make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting the existing code. React can also render on the server using Node and power mobile apps using React Native.
To download or browse the code visit the repository via this link
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
git clone https://github.com/eminmuhammadi/emeega.git
For installing this project, individuals should run this bash command
composer install && npm install
Stage of project
- Production
npm run production
- Development
npm run dev
NOTE: You can easily configure environment files using .env
file extension
PUBLIC_URL=
PUBLIC_PATH=/public
BUNDLE_PATH=/public/build
Alright, now let’s get to it!
Requirements: You need Node.js and npm installed on your local machine. As well as a XAMPP, WAMP or any other web server solution.
The simple structure of index.php
file
But React?
First of all, you need to analyze webpack.config.js
file.
Attention~ Please be careful when configuring this file
.addEntry('js/app', './assets/js/index.js') .addStyleEntry('css/app', './assets/scss/global.scss')
It must be correct in that way!
So,
You can easily create or paste existed React Project on assets/js/
folder
Assets
| — assets/js/
[+] SCSS (SASS)
| — assets/scss/
[+] HTML (PHP Twig)
| — assets/view/
Features
- Develop React on a local machine to deploy the whole website on cheap PHP hosting services
- Easily editable SCC files
- Easily editable .twig files
- Easily editable PHP files to enlarge of scalability of the current project
Feel free to contact us or contribute our project
Author: Emin Muhammadi (https://muemin.me). You can contact here for ideas and suggestions.