{"id":15,"date":"2026-11-21T12:00:00","date_gmt":"2026-11-21T12:00:00","guid":{"rendered":"https:\/\/php127.hazyhaar.fr\/blog\/?p=15"},"modified":"2026-11-22T04:03:16","modified_gmt":"2026-11-22T04:03:16","slug":"en-01-why-rewrite-php-in-go","status":"publish","type":"post","link":"https:\/\/php127.hazyhaar.fr\/blog\/en-01-why-rewrite-php-in-go\/","title":{"rendered":"Why rewrite PHP in Go"},"content":{"rendered":"<p>php127 is a PHP runtime written in Go. It reads the same source code as PHP, compiles it to its own intermediate code and runs it in its own virtual machine. The behaviour it aims for is that of PHP 8.3.6, which serves as the reference in every test bench: when php127 and PHP 8.3.6 do not return the same thing, php127 is the one at fault. This article explains why the project exists, what it is trying to achieve and what it is not. Every figure quoted carries its date and the measurement file that contains it; the full list is in the blog&#039;s source record.<\/p>\n<h2>The goal<\/h2>\n<p>On 2026-11-20 the goal of the project was set in one sentence: offer a runtime to the PHP community. The decision is recorded in the project&#039;s decision log (<code>decisions.md<\/code>). It has a practical consequence for the way the work is done. Running the libraries and frameworks in common use, namely Composer, Symfony, Laravel, Twig, PHPUnit and PrestaShop, is part of the work itself, not a wish list to be dealt with some day.<\/p>\n<p>Why Go rather than a change to the C interpreter? The three reasons below come from the properties of the result, not from a taste for one language.<\/p>\n<h3>A binary without C libraries<\/h3>\n<p>php127 is built with <code>CGO_ENABLED=0<\/code>. The resulting binary calls no C library from the system. SQLite and regular expressions go through Go libraries declared in the project&#039;s module file (<code>modernc.org\/sqlite<\/code> and <code>go.elara.ws\/pcre<\/code>), and the network protocol of MySQL and MariaDB is spoken by a driver written in Go, the <code>mysqlpilote<\/code> package. Putting php127 on a machine means copying one file onto it; the article on installation shows the commands.<\/p>\n<h3>Isolated requests<\/h3>\n<p>The <code>zone<\/code> package provides one memory arena per request. PHP strings, arrays and objects live in it, and the arena is wiped when the request ends. Streams, sessions and the state of regular expressions are also held per request, as the descriptions of the <code>streams<\/code>, <code>session<\/code> and <code>pcre<\/code> packages state. This reset concerns the arena; the compiled-program cache remains shared between requests in server mode (<code>sapi\/fpm\/cache.go<\/code>). It does not by itself demonstrate isolation of every process state.<\/p>\n<h3>Code that can be checked<\/h3>\n<p>Each part of the runtime is a Go package with its own tests. On top of them, the acceptance benches run PHP 8.3.6 and php127 side by side on the same code, WordPress, PrestaShop, Symfony or Composer, and compare their output. This setup makes every discrepancy visible and datable. That is the condition for showing it, as this blog does, instead of estimating it.<\/p>\n<h2>What the project is not<\/h2>\n<p>php127 is not a faster PHP. The measurements of 2026-11-20 on revision e0a4a88 show, on five micro-benchmarks, between 6 and 25 times as many machine instructions per operation as PHP 8.3.6 (<code>diagnostic-boucle.out.md<\/code>). The article on speed details these historical measurements, their method and their causes; they do not measure reference revision 5b31e86.<\/p>\n<p>php127 is not complete. The historical count recorded on 2026-11-21 at 18:46, revision 11f6d94, is 11,270 tests passed out of 11,906 (<code>dettes.md<\/code>), leaving 636 without a pass under that run&#039;s counting rule. It does not describe reference revision 5b31e86; the conformance article gives the updated count using the official runner&#039;s names. In addition, some areas have been removed from the target by decision: the <code>exif<\/code> and <code>sodium<\/code> extensions, opcache, <code>zend.multibyte<\/code> and <code>declare(ticks)<\/code>. The article on what changes compared to PHP lists them and gives the reasons.<\/p>\n<p>php127 is not a branch of the PHP code base. The lexer, the parser, the compiler and the virtual machine are Go packages of the project (<code>lexer<\/code>, <code>parser<\/code>, <code>compiler<\/code>, <code>vm<\/code>), and none of them calls the PHP interpreter. Extensions also rely on external Go modules: SQLite and PCRE are not implemented entirely inside the project tree, as the module file shows.<\/p>\n<p>php127 is not, as of the date of this article, a runtime whose security has been tested as a whole. The security checks on record cover <code>open_basedir<\/code> and the rejection of external XML entities; the article on security says what was checked, by whom, and what was not. Finally, php127 does not talk to PostgreSQL: its database drivers cover MySQL, MariaDB and SQLite.<\/p>\n<h2>Why a site served by php127<\/h2>\n<p>The site that publishes this blog is a PrestaShop shop and a WordPress blog, both served by php127 behind nginx. This choice turns the site into a demonstration: every page you read here was executed by the runtime it describes. It also has a downside, which we would rather state: an outage of the site is an outage of php127, and it will show.<\/p>\n<p>The shop presents the offer of migration audit hours for php127. Sales are not open: ordering will open after the company is registered and the legal notices are completed. An audit means replaying an application&#039;s test suite under php127 and drawing up the list of discrepancies. It is the same work as the one these articles describe, applied to a client&#039;s code.<\/p>\n<h2>What this blog covers<\/h2>\n<p>The ten articles follow a simple order. After this one come installation, the internals, then the differences from PHP. Next come measured conformance, WordPress, PrestaShop, then Symfony and Composer, and finally speed and security. The articles on conformance, speed and security keep their figures in a data block at the top, with the date and source file of each one, so that they can be regenerated from the measurement files instead of being copied by hand.<\/p>\n<p>What these articles do not do is promise. When a defect is known, it is written down with its date; when a fix is being considered, it is described as work to be done, with no delivery date.<\/p>\n<p class=\"php127-traduction\"><a rel=\"alternate\" hreflang=\"fr\" href=\"https:\/\/php127.hazyhaar.fr\/blog\/fr-01-pourquoi-reecrire-php-en-go\/\">Lire en fran\u00e7ais<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>php127 is a PHP runtime written in Go. It reads the same source code as PHP, compiles it to its own intermediate code and runs it in its own virtual machine. The behaviour it aims for is that of PHP 8.3.6, which serves as the reference in every test bench: when php127 and PHP 8.3.6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-en"],"_links":{"self":[{"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":2,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions\/59"}],"wp:attachment":[{"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/php127.hazyhaar.fr\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}