Search code examples
phphhvmhacklang

Codeigniter and Hack Language


I am wondering how and if it is possible to run Hack code with HHVM in codeigniter models and controllers.

Also are there any active efforts to port PHP frameworks like CI into Hack?


Solution

  • I am wondering how and if it is possible to run Hack code with HHVM in codeigniter models and controllers.

    Yep! Hack has full backwards compatibility with PHP. You should start by making sure that CodeIgniter runs on HHVM. 100% of its unit tests are passing on HHVM, so I expect that you'll have very good luck with this.

    Then, you can just start writing Hack code right alongside CodeIgniter. HHVM will allow Hack to call into PHP and PHP to call into Hack with no problems. The Hack type system won't know anything about the PHP code, so it won't be able to help you with type errors at the boundary, but everything will work.

    Also are there any active efforts to port PHP frameworks like CI into Hack?

    I'm not aware of any right now. Contrary to what the other answer said, this would definitely be a useful thing to do though! Even if CI didn't want to take advantage of the many benefits of the Hack language, if they even wanted to add type annotations, that would definitely help anyone who wanted to use CI with Hack! So converting an existing project to Hack has definite benefits for users, and then you can continue to gradually use more of the features of Hack.

    The major problem is that Hack only runs on HHVM; existing users of CI wouldn't be able to use the PHP5 engine. The Hack team has a solution for this we're going to announce very soon, stay tuned :)