Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HHVM for PHP and Hack

Mariusz Gil
September 27, 2014

HHVM for PHP and Hack

Mariusz Gil

September 27, 2014
Tweet

More Decks by Mariusz Gil

Other Decks in Programming

Transcript

  1. HHVM OPEN SOURCE VIRTUAL MACHINE FOR PHP PHP5 SUPPORT* HACK

    SUPPORT JIT COMPILATION HHVM NATIVE INTERFACE FAST CGI SUPPORT CLI SUPPORT HPHPD
  2. cat ./phpversion.php <?php ! var_dump(phpversion()); ! ! php -f ./phpversion.php

    string(16) "5.5.9-1ubuntu4.4" ! ! hhvm -f ./phpversion.php string(11) "5.6.99-hhvm"
  3. cd/var/www/webapp; ! hhvm --mode server -vServer.Type=fastcgi -vServer.FileSocket=/var/run/hhvm/hhvm.sock -vAdminServer.Port=9001 ! !

    root /var/www/webapp; fastcgi_pass unix:/var/run/hhvm/hhvm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
  4. HACK LANGUAGE FOR HHVM THAT INTEROPERATE SEAMLESSLY WITH PHP TYPE

    ANNOTATIONS TYPE ALIASING GENERICS NULLABLE TYPES COLLECTIONS CONTINUATIONS LAMBDAS ASYNC PROGRAMMING SHAPES TUPLES
  5. <?hh ! class Mailbox<T> { private ?T $data; ! public

    function __construct() { $this->data = null; } ! public function put(T $mail): void { $this->data = $mail; } ! public function check(): ?T { if ($this->data !== null) { return $this->data; } return null; } }
  6. cat ./test.hh <?hh ! function f(): Vector<T> { return 'not

    an Vector<T>'; } ! ! hh_client /home/vagrant/test.hh:3:22,22: You probably forgot to bind this type parameter right? Add <T> somewhere (after the function name definition, or after the class name) Examples: function foo<T> or class A<T> /home/vagrant/test.hh:4:10,27: Invalid return type /home/vagrant/test.hh:3:15,20: This is an object of type Vector /home/vagrant/test.hh:4:10,27: It is incompatible with a string
  7. sapi/cli/php -v PHP 7.0.0-dev (cli) (built: Sep 25 2014 22:05:10)

    Copyright (c) 1997-2014 The PHP Group Zend Engine v2.8.0-dev, Copyright (c) 1998-2014 Zend Technologies