0

React js as frontend and php as backend

I saw couple of videos in YouTube about using react js as frontend and php as backend, do you think this approach will be successful?

13th Jun 2018, 6:00 AM
ahmed alhameli
ahmed alhameli - avatar
6 odpowiedzi
+ 1
React is an open-source JavaScript library providing a view for data rendered as hyper text markup language. React, in case you’re not familiar with it, is a library for front-end web development. You use it to create components: little not-really-HTML tags that you can compose together to create your UI.So using it for front end is better than using it for server side , Php is one of the best server side language , So use pHp for back end
13th Jun 2018, 6:06 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
mr.Ahmed for this exist tow possibility. First is in package.json must add example "proxy": "http://localhost:80" for use php, make folder one for react client and another for php. React app must have some like this Brisanje(e){ fetch('http://localhost/fetchReact/server/prijem.php',{ method: 'POST', headers: { Accept: 'application/json', 'Content-Type':'application/json' }, body: JSON.stringify({ content: this.state.name }), }) .then( res=> res.json()) .then( response => { console.log(response); alert(response.message); }); } for calling index.php file. And in index.php needed code <?php header('Accept: application/json'); header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE,OPTIONS'); header("Access-Control-Allow-Headers: eToken,X-Requested-With,Content-Type"); header('Content-type: text/json; charset=utf-8; application/x-www-form-urlencoded'); header('Access-Control-Allow-Origin: *'); ini_set('xdebug.overload_var_dump', 0); include 'funkcije.php'; $requestData = json_decode(file_get_contents('php://input'), true); if(!isset($requestData)) { $requestData = $_POST; if(!isset($requestData) && count($requestData) == 0) { response(null, "No request data.", true); return; } } if(!isset($requestData['requestName'])) { response(null, "No requestName in request data.", true); return; } switch ($requestData['requestName']) { case RN_LOGIN: $result = login($requestData['email'], $requestData['sifra']); response($result); break; case "logOut": logout(); break;
9th Feb 2019, 5:23 PM
Miodrag Trajanovic
Miodrag Trajanovic - avatar
+ 1
next is in file function.php make funcitions for server action
9th Feb 2019, 5:24 PM
Miodrag Trajanovic
Miodrag Trajanovic - avatar
+ 1
thanks very nice
9th Feb 2019, 5:26 PM
ahmed alhameli
ahmed alhameli - avatar
0
ঝরা ফুলের পাপড়ি> কিছু ভালোবাসা জীবন টাকে রঙ্গীন করে দেয়.., কিছু ভালোবাসা জীবনের সব ভালোবাসা কেড়ে নেয়..| কিছু স্বপ্ন দু ঠোটে হাসি ফোটায়..., আর কিছু স্বপ্ন দু চোখে অশ্রু ঝড়ায়...| স্বপ্নের বাস্তবতা বহুদুর...!!! কিছু ভুল জীবনের সব ভুল গুলো শুধ রিয়ে দেয়..., আর কিছু ভুল জীবনে চলার পথটাকে নষ্ট করে দেয়...|
2nd Apr 2020, 4:02 AM
Md Jobayar Islam Jobayar
0
no active avri body
2nd Apr 2020, 4:02 AM
Md Jobayar Islam Jobayar