Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HipHop for PHP, deploying apps

Tags:

hhvm

After Googling, I found a lot of HipHop documentation, but plenty was posted between 2011 and 2013.

Earlier this year was launched a new version of HipHop that even supports Drupal and includes a lot of improvements...

I've always used the Zend Guard to deploy my commercial applications, but now I started to consider seriously the use of HipHop in production, but here comes the question:

  • We can run an application using only the bytecode HHBC (Without .php source code)?

Follows the reference of my research https://github.com/facebook/hhvm/wiki/FAQ

The question may seem very obvious, but it is not so easy to find this answer in the project documentation.

Thanks in advance!

like image 944
Ragen Dazs Avatar asked Oct 21 '22 15:10

Ragen Dazs


1 Answers

Well, yes and no.

HHVM has a so-called RepoAuthoritative mode in which the HHVM will no longer check the existence of the PHP files or how up-to-date they are; instead, it will retrieve the HHBC directly from its cache.

Theoretically, you can follow these steps:

  • pre-generate the HHBC for all your PHP files and insert that HHBC in HHVM's cache. This is the so-called pre-analysis phase (if you ever see it in HHVM documentation, this is what they mean by it)
  • turn on RepoAuthoritative mode (it's just 1 line in HHVM's config)
  • delete your PHP code

This way your PHP applications will run just fine without the source code being present. Doing a server restart won't change this since HHVM's bytecode cache lives on disk (it's implemented as an SQLite database).

However, it will be kind of a headache if you:

  • want to change something in your code. You would have to copy your code, make the change and repeat the pre-analysis phase.
  • want to upgrade HHVM to a newer version. HHVM uses its build ID as part of the cache key so, if you upgrade it, the bytecode cache becomes unreachable and, since you'll be running in RepoAuthoritative mode, your application will be reduced to a bunch of HTTP 404 errors. To fix this, you would have to repeat the pre-analysis phase as well.

Bottom line: no upside, big downside. There's just no point in doing it.

PS: I hope I answered your question. It's also possible that I misunderstood what you asked; if that's the case, please let me know in a comment.

like image 59
Radu Murzea Avatar answered Oct 24 '22 01:10

Radu Murzea