Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I did a couple of quick tests <em>(haven't have the time to play with hiphop as much as I'd like, unfortunately ;-( )</em> ; here are the results I got :</p> <p><br></p> <hr> <p>First of all, here's the content of <code>test-2.php</code>, which contains a parse error :</p> <pre><code>&lt;?php echo "what with a parse error ? </code></pre> <p><em>Note : the string is not finished</em></p> <p><br> Trying to run that with PHP, I get :</p> <pre><code>$ php test-2.php PHP Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /home/squale/temp/hiphop-php/tests/test-2.php on line 5 Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /home/squale/temp/hiphop-php/tests/test-2.php on line 5 </code></pre> <p><br> Trying to compile that with hiphop, I get :</p> <pre><code>$ /home/squale/temp/hiphop-php/hiphop-php/src/hphp/hphp test-2.php --keep-tempdir=1 --log=3 running hphp... creating temporary directory /tmp/hphp_JdsWcU ... parsing inputs... parsing ./test-2.php... parsing inputs took 0'00" (0 ms) wall time running hphp took 0'00" (154 ms) wall time Exception: Unable to parse file: ./test-2.php (Line: 5, Char: 0): syntax error, unexpected $end </code></pre> <p>i.e. the file with the parse error doesn't compile -- which stands to reason.</p> <p>The error message has some informations that were present in the PHP's error message -- but not exactly as precise...</p> <p>Which means you might want to try with PHP before trying to compile your application with hiphop : the error message given by PHP was more descriptive.</p> <p><br></p> <hr> <p>Now, let's try with some runtime errors/warnings ; here's the content of <code>test-1.php</code> :</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', 'On'); if ($_GET['test'] == '1') { $data = (object)array(10); echo $data[0]; } else if ($_GET['test'] == '2') { echo 10/0; } else if ($_GET['test'] == '3') { file_put_contents('/bin/non-allowed', 'hello !'); } echo "plop\n"; </code></pre> <p>Trying to run that file from Apache+PHP, you'd get three possible errors : <br><em>(I copied the file to my document root -- which means the paths will not be the same for the errors with Apache)</em></p> <p>First of all, calling <code>http://localhost/temp/test-1.php?test=1</code> I get :</p> <pre><code>Fatal error: Cannot use object of type stdClass as array in /home/squale/developpement/tests/temp/test-1.php on line 8 </code></pre> <p>And, trying <code>http://localhost/temp/test-1.php?test=2</code> I get :</p> <pre><code>Warning: Division by zero in /home/squale/developpement/tests/temp/test-1.php on line 10 plop </code></pre> <p>And, finally, with <code>http://localhost/temp/test-1.php?test=3</code>, I get :</p> <pre><code>Warning: file_put_contents(/bin/non-allowed) [function.file-put-contents]: failed to open stream: Permission denied in /home/squale/developpement/tests/temp/test-1.php on line 12 plop </code></pre> <p><br> Now, compiling that <code>test-1.php</code> file with hiphop and running it in web-server mode, I get this during the compilation phase, which means it is OK :</p> <pre><code>$ /home/squale/temp/hiphop-php/hiphop-php/src/hphp/hphp test-1.php --keep-tempdir=1 --log=3 running hphp... creating temporary directory /tmp/hphp_xXZ8US ... parsing inputs... parsing ./test-1.php... parsing inputs took 0'00" (1 ms) wall time pre-optimizing... pre-optimizing took 0'00" (0 ms) wall time inferring types... inferring types took 0'00" (0 ms) wall time post-optimizing... post-optimizing took 0'00" (0 ms) wall time creating CPP files... creating CPP files took 0'00" (32 ms) wall time compiling and linking CPP files... compiling and linking CPP files took 0'39" (39807 ms) wall time running executable /tmp/hphp_xXZ8US/program --file test-1.php... plop all files saved in /tmp/hphp_xXZ8US ... running hphp took 0'40" (40054 ms) wall time </code></pre> <p>And, then, launching the server :</p> <pre><code>$ /tmp/hphp_xXZ8US/program -m server -p 8080 Could not mlockall loading static content... loading static content took 0'00" (0 ms) wall time page server started admin server started all servers started </code></pre> <p><br> Now, let's try accessing those three URLs ; first, calling <code>http://localhost:8080/test-1.php?test=1</code> I get :</p> <ul> <li>Nothing in the browser</li> <li><code>Unhandled error: Invalid operand type was used: not ArrayAccess objects.</code> in the console from which I started the server</li> </ul> <p>For <code>http://localhost:8080/test-1.php?test=2</code>, I get :</p> <ul> <li>In the browser : <code>plop</code></li> <li>In the console from which I started the browser : <code>Division by zero</code></li> </ul> <p>And, finally, for <code>http://localhost:8080/test-1.php?test=3</code>, I get :</p> <ul> <li>In the browser : <code>plop</code></li> <li>In the console : <em>nothing</em></li> </ul> <p>Here, too, indications of errors are not quite as good as with PHP... at least with default options...</p> <p><br></p> <hr> <p>Judging from hiphop's <a href="http://wiki.github.com/facebook/hiphop-php/runtime-options" rel="noreferrer">Runtime options wiki page</a>, you can specify a config file that contains some options. <br>Here's the content of the <code>config.txt</code> I used :</p> <pre><code>Log { Level = Verbose NoSilencer = true AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 6143 Header = false InjectedStackTrace = true NativeStackTrace = true MaxMessagesPerRequest = -1 } ErrorHandling { CallUserHandlerOnFatals = true NoInfiniteLoopDetection = false NoInfiniteRecursionDetection = false MaxStackDepth = 1000 ThrowBadTypeExceptions = true ThrowNotices = true NoticeFrequency = 1 # 1 out of these many notices to log WarningFrequency = 1 # 1 out of these many warnings to log AssertActive = false AssertWarning = false } </code></pre> <p><br> Re-starting the server, using the <code>--config</code> switch to point to that file :</p> <pre><code>$ /tmp/hphp_xXZ8US/program -m server -p 8080 --config=config.txt Could not mlockall loading static content... loading static content took 0'00" (0 ms) wall time page server started admin server started all servers started </code></pre> <p>I should get more informations... let's try our three requests again.</p> <p><br></p> <p>First, calling <code>http://localhost:8080/test-1.php?test=1</code> I get :</p> <ul> <li>Same as before</li> </ul> <p>For <code>http://localhost:8080/test-1.php?test=2</code>, I get :</p> <ul> <li>Same as before</li> </ul> <p>And, finally, for <code>http://localhost:8080/test-1.php?test=3</code>, I get :</p> <ul> <li>In the browser : <code>plop</code></li> <li>In the console : a new error message that I didn't get before : <code>f_file_put_contents/316: Permission denied</code></li> </ul> <p><br> I didn't try much more, but playing with that config file and the <code>--config</code> switch looks like an interesting idea ;-)</p> <p><br></p> <hr> <p>Note : I did those tests on Ubuntu 9.10 64bits -- which is an officially supported system ; installation was quite easy.</p> <p>Which means you could try those, doing an install in a Virtual Machine, for example : as long as you know a bit about Linux and compiling software, installing hiphop is not an impossible task.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload