react-php-v8js icon indicating copy to clipboard operation
react-php-v8js copied to clipboard

$this->v8->executeString() needs to be echoed in ReactJS.php

Open rickmurt opened this issue 10 years ago • 7 comments
trafficstars

I did a cURL on the page I set up to verify that PHP had indeed echoed both the markup and the JS, and what I found was that the JS was outputted, but the markup didn't get generated until the page loaded (curl request resulted in <div id="page"></div>). When I inspected the table element, the data was there, so the JS initialized it. If you view source immediately, you'll see an empty #page as well.

Since you have an output buffer in ReactJS::getMarkup(), you have to echo, like so:

ob_start();
*echo* $this->v8->executeString($js);      
return ob_get_clean();

Once I added the echo and did a cURL request, I noticed that the markup was actually there before the JS had a chance to render it.

I'd put in a pull request, but I just wanted to verify that this was intended behavior and I wasn't missing anything.

rickmurt avatar Feb 24 '15 00:02 rickmurt

This repo isn't super active so I'm not sure if you'll get a good response, but cc @stoyan for good measure.

zpao avatar Feb 24 '15 01:02 zpao

@zpao if this repo is not active, do you know if this lib is still developed? So much noise about React these days, and I think to try it out with PHP, and google search gives this library as a first result.

ddon avatar Feb 26 '15 09:02 ddon

It's not being used by us and it has basically not been updated since release (https://github.com/reactjs/react-php-v8js/commits/master). There is really not a ton to do here since the feature set is very small. It would be great to have some tests and then we can sort of coast.

zpao avatar Feb 26 '15 19:02 zpao

What is the alternative? Not using anything or is it closed source?

allantatter avatar Mar 21 '15 15:03 allantatter

We don't use this or anything like it.

zpao avatar Mar 23 '15 20:03 zpao

@rickmurt Thats not true, because the executed JS Code (https://github.com/reactjs/react-php-v8js/blob/master/ReactJS.php#L109) contains a print() function which is a php-v8js special global function that does echo (or print which is basically the same in php) the result. So this should work. See the v8js js api: https://github.com/preillyme/v8js#javascript-api and the examples below.

carlos22 avatar Apr 13 '15 19:04 carlos22

good

rahim76 avatar Jul 14 '18 05:07 rahim76