Hiphop Learning Research

Source: Internet
Author: User

HipHop converts PHP code into highly optimized C ++ code and then compiles it with the g ++ compiler.

The code generated by HipHop uses static binding of functions and variables as much as possible.
The conversion process is divided into three steps:
1. Static Analysis. Collect declarative and dependency information.
2. Type deduction. Which of the following is the scalar of C ++? Or String, Array, classes, Object or Variant.
3. Code Generation. Most PHP statements and expressions are directly mapped to C ++ statements and expressions.

The completion of hiphop compilation is just the start of hiphop-> hiphop comes with the hphpi Server

HPHPi is an experimental interpreter. It can also be run without compiling the PHP source code. It has been used for debugging of HipHop itself.

Note: nginx is not required. If necessary, it is used as a front-end proxy to bring some web Server additional functions required by users.

After the environment is installed

Pre-compilation Configuration:

Setenv HPHP_HOME/usr/local/src/freebsd-hiphop-php
Setenv HPHP_LIB/usr/local/src/freebsd-hiphop-php/bin
Setenv CMAKE_PREFIX_PATH/services/hipop-php-include
Setenv CC/usr/local/bin/gcc44
Setenv CXX/usr/local/bin/g ++ 44

Compile 1 single file
1./usr/local/src/freebsd-hiphop-php/src/hphp test. php -- keep-tempdir = 1 -- log = 3
2./tmp/hphp_p6vSsP/program-m server-p 8080
3. curl http: // localhost: 8080/test. php

Compile two or more files
1. find.-name "*. *"> files. list
2. /usr/local/src/freebsd-hiphop-php/src/hphp -- input-list = files. list-k 1 -- log = 3 -- include-path = ". "-- output-dir =/tmp/test -- force = 1 -- cluster-count = 50-v" AllDynamic = true "-v" AllVolatile = true"
3. /tmp/hphp_DwhCB8/program-m server-v "Server. sourceRoot =/tmp/hphp_DwhCB8 "-v" Server. defaultDocument = index. php "-c/usr/local/src/freebsd-hiphop-php/bin/mime. hdf-p 8080

Use hphpi to compile instances
1./usr/local/src/freebsd-hiphop-php/src/hphpi-f curlTest. php
2. sudo/usr/local/src/freebsd-hiphop-php/src/hphpi-m server-p 8088

Hphp compiled program is a complete site that can listen to ports by itself, without the need for apache, nginx, and other web Servers

Note:
1. Compile common options hphp/hphp
-- Input-list = files. List // used for multiple files (a single file directly writes the file name)
-- Keep-tempdir = 1 // [Abbreviation:-K 1]
-- Log = 3 // indicates the compiled log level. Generally, 3 is enabled, and all useful information is displayed.
-- Force = 1 // even if both warning and error force compile the code, errors and alarms will be reflected in the report.
-- Gen-Stats = 1 // do you need to generate code status and code error reports?
-- Include-Path = "." // include the code file directory that appears in the include statement
-- Cluster-Count = 50 // if this parameter is not set, several PHP files will generate several CPP files, resulting in a longer compilation process. If the base number is too large, you can enable this parameter.
-- Output-Dir =/tmp // directory for storing compiled files. The default value is/tmp.
-- Program = projectname //
-V "alldynamic = true" // supports dynamic function calls and dynamic method calls.
-V "allvolatile = true" // supports dynamic function and class declaration.

2. The running parameters are as follows:
./Program
Options:
-- Help display this message
-M [-- mode] Arg (= run) Run | Server | daemon | replay | translate
-C [-- config] arg load specified config file
-V [-- config-value] arg individual configuration string in a format
Of name = value, where name can be any valid
Configuration for a config file
-P [-- port] arg (=-1) start an HTTP server at specified port
-- Admin-port arg (=-1) start admin listerner at specified port
-U [-- user] arg run server under this user account
-F [-- file] arg executing specified file
-- Count arg (= 1) how many times to repeat execution
-- No-safe-access-check arg (= 0) whether to ignore safe file access check
-- Arg arguments
-- Extra-header arg extra-header to add to log lines
-- Build-id arg unique identifier of compiled server code
-- Xhprof-flags arg (= 0) Set XHProf flags

Official:
Https://github.com/facebook/hiphop-php

Https://github.com/facebook/hiphop-php/wiki/using-nginx-as-front-server-to-hiphop

Run hiphop
Https://github.com/facebook/hiphop-php/wiki/running-hiphop
Runtime options
Https://github.com/facebook/hiphop-php/wiki/Runtime-options

Other references

Http://xenojoshua.com/tag/hiphop-php/

Http://huichen.org/en/2010/07/hiphop-for-freebsd/

Http://blog.csdn.net/cyberexp2008/article/details/6756826

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.