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 Answers
+ 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