takafumi blog

日々の勉強メモ

hhvm Hack その2/とりあえず動かしてみる

CentOS6.5 hhvm3.2.0



hhvmを動かしてみる

ちなみにhhvmのオプションはこんな感じ

$ hhvm --help
Usage:

   hhvm [-m <mode>] [<options>] [<arg1>] [<arg2>] ...

Options:
  --help                                display this message
  --version                             display version number
  --php                                 emulate the standard php command line
  --compiler-id                         display the git hash for the compiler
  --repo-schema                         display the repository schema id
  -m [ --mode ] arg (=run)              run | debug (d) | server (s) | daemon |
                                        replay | translate (t)
  -a [ --interactive ]                  Shortcut for --mode debug
  -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
  --no-config                           don't use the default php.ini
  -p [ --port ] arg (=-1)               start an HTTP server at specified port
  --port-fd arg (=-1)                   use specified fd instead of creating a
                                        socket
  --ssl-port-fd arg (=-1)               use specified fd for SSL instead of
                                        creating a socket
  --admin-port arg (=-1)                start admin listener at specified port
  --debug-config arg                    load specified debugger config file
  -h [ --debug-host ] [=arg(=localhost)]
                                        connect to debugger server at specified
                                        address
  --debug-port arg (=-1)                connect to debugger server at specified
                                        port
  --debug-extension arg                 PHP file that extends y command
  --debug-cmd arg                       executes this debugger command and
                                        returns its output in stdout
  --debug-sandbox arg (=default)        initial sandbox to attach to when
                                        debugger is started
  -u [ --user ] arg                     run server under this user account
  -f [ --file ] arg                     executing specified file
  -l [ --lint ] arg                     lint specified file
  -w [ --show ] arg                     output specified file and do nothing
                                        else
  --temp-file                           file specified is temporary and removed
                                        after execution
  --count arg (=1)                      how many times to repeat execution
  --no-safe-access-check arg (=0)       whether to ignore safe file access
                                        check
  --arg arg                             arguments
  --extra-header arg                    extra-header to add to log lines
  --build-id arg                        unique identifier of compiled server
                                        code
  --instance-id arg                     unique identifier of server instance
  --xhprof-flags arg (=0)               Set XHProf flags

上記に乗ってないけど、--hphpでhphpコンパイラとして動かせます。
ただ hhvm --hphp と打つとhelpが出ます。

hhvmはphpファイルを実行できます。またhhのファイルは

$ echo '<?php echo "Hello PHP on hhvm\n";'  > hello.php
$ echo '<?hh  echo "Hello Hack on hhvm\n";' > hello.hh

$ hhvm hello.php
Hello PHP on hhvm
$ hhvm hello.hh
Hello Hack on hhvm

phpphpコマンド以外で動かすは、なんか不思議ですね。

ちなみに標準入力は受け取ってくれない模様
$ echo '<?php echo "normal input\n";' | php
normal input
$ echo '<?php echo "normal input\n";' | hhvm
Nothing to do. Either pass a .php file to run, or use -m server

phpとの相違点は
PHPer必見!最強PHPerになれると噂の「新言語Hack」を試してみよう! | 株式会社LIG
がわかりやすいです。