Documentation

php2go documentation

A practical user guide: prepare a ZIP, choose an entrypoint, run allowed commands, download the artifact, and understand common compiler errors.

Fast path to the first build
  1. Pack the project into a ZIP without secrets or junk files.
  2. Make sure the entrypoint exists, usually public/index.php.
  3. Run report/check/deps before compile.
  4. Download the artifact and run the binary using README_RUN.
CONCEPT

What php2go is

php2go is a compiler and managed build service for PHP projects. It analyzes source code, generates Go code, links a compatibility runtime, and builds an executable binary that can run without PHP-FPM.

What the compiler does

  • Reads PHP files, classes, functions, require/include calls, and Composer autoload.
  • Understands types, arrays, object properties, method calls, and common PHP patterns.
  • Generates Go code and replaces PHP runtime calls with direct Go where it is safe.
  • Builds a binary, manifest, logs, and run instructions into one artifact.

What it is not

  • It is not a PHP interpreter and not a wrapper around php-fpm.
  • It does not magically rewrite business logic into another framework.
  • It is not shell access to the server: commands are limited and validated.
  • It does not promise that every arbitrary PHP project builds without diagnostics.
Why it is useful

The main value is a portable deploy artifact, faster legacy-code checks, less dependency on the PHP environment, and visible compatibility problems before production.