PHP için HipHop ile, ne PHP hataları ile olur

1 Cevap php

HipHop C çalıştırılabilir PHP derler. Ne PHP hataları ile olur?

Zor ayıklamak için mi?

edit: Ben belgelere baktım ama bir şey bulamadık

1 Cevap

Ben hızlı testler (haven't have the time to play with hiphop as much as I'd like, unfortunately ;-( ) bir çift yaptım; burada aldım sonuçları:



Her şeyden önce, burada bir ayrıştırma hatası içeren, test-2.php içeriği bulunuyor:

<?php

echo "what with a parse error ?

Note : the string is not finished


Trying to run that with PHP, I get :

$ 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


Trying to compile that with hiphop, I get :

$ /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

yani ayrıştırma hatası ile dosya derleme değil - nedenle duruyor hangi.

Hata iletisi PHP'nin hata mesajında ​​mevcut olan bazı bilgiler var - ama tam olarak kesin değil ...

PHP tarafından verilen hata mesajı daha açıklayıcı oldu: Hangi hiphop ile uygulama derlemeye çalışırken önce PHP ile denemek isteyebilirsiniz demektir.



Şimdi, bazı çalışma zamanı hatalar / uyarılar ile çalışalım; Buradan içeriğin test-1.php:

<?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";

Trying to run that file from Apache+PHP, you'd get three possible errors :
(I copied the file to my document root -- which means the paths will not be the same for the errors with Apache)

Her şeyden önce, çağrı http://localhost/temp/test-1.php?test=1 alıyorum:

Fatal error: Cannot use object of type stdClass as array in /home/squale/developpement/tests/temp/test-1.php on line 8

Ve çalışırken http://localhost/temp/test-1.php?test=2 alıyorum:

Warning: Division by zero in /home/squale/developpement/tests/temp/test-1.php on line 10
plop 

Ve nihayet, ile http://localhost/temp/test-1.php?test=3, alıyorum:

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


Now, compiling that test-1.php file with hiphop and running it in web-server mode, I get this during the compilation phase, which means it is OK :

$ /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

Ve sonra, sunucuyu başlatıyoruz:

$ /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


Now, let's try accessing those three URLs ; first, calling http://localhost:8080/test-1.php?test=1 I get :

  • Tarayıcıda hiçbir şey
  • Unhandled error: Invalid operand type was used: not ArrayAccess objects. Ben sunucuyu başlatan hangi konsolda

Için http://localhost:8080/test-1.php?test=2, alıyorum:

  • Tarayıcıda: plop
  • Ben tarayıcı başladım hangi konsolda: Division by zero

Ve nihayet, için http://localhost:8080/test-1.php?test=3, alıyorum:

  • Tarayıcıda: plop
  • Konsolda: nothing

Burada da, hataları endikasyonları PHP gibi ... en azından varsayılan seçenekleri ile oldukça iyi değil ...



Judging from hiphop's Runtime options wiki page, you can specify a config file that contains some options.
Here's the content of the config.txt I used :

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
  }


Re-starting the server, using the --config switch to point to that file :

$ /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

Ben yine bizim üç isteği deneyelim ... daha fazla bilgi almalısınız.


İlk olarak, çağrı http://localhost:8080/test-1.php?test=1 alıyorum:

  • Önce olduğu gibi aynı

Için http://localhost:8080/test-1.php?test=2, alıyorum:

  • Önce olduğu gibi aynı

Ve nihayet, için http://localhost:8080/test-1.php?test=3, alıyorum:

  • Tarayıcıda: plop
  • Konsolda: Ben alamadım yeni bir hata iletisi önce: f_file_put_contents/316: Permission denied


I didn't try much more, but playing with that config file and the --config switch looks like an interesting idea ;-)



Not: Ben Ubuntu 9.10 64bits üzerinde bu testler yaptı - resmi olarak desteklenen bir sistemdir; kurulumu oldukça kolay oldu.

Yapıyorsun, o deneyebilirsiniz anlamına gelir bir örnek için, bir Virtual Machine yükleyin: sürece hiphop yükleme, Linux ve derleme yazılım hakkında biraz bildiğiniz gibi imkansız bir görev değildir.