Skip to content

Compiling a production Laravel 13 API: 9 PHP 8.5 constructs that fail to compile, plus build feedback #614

Open

Description

@EduardoMateos

@blacktrs Hi! First of all, I honestly don't know if issues like this are useful to you, so feel free to close it, split it up or just ignore it. I mainly wanted to give some feedback, because what you're doing with this project is crazy (in the good sense). A PHP compiler written in PHP that compiles itself, and that can get a real Laravel app this far? Hats off.

I tried it on the API we run in production: Laravel 13, around 930 files in app/ and 150 Composer packages (Google Cloud, Adyen, Sentry, phpseclib, mPDF…). I followed examples/laravel-app, and the recipe worked as described. Some things that blocked me back on 0.16 are already fixed (enum as a class name, " inside {$…}, $cls::{$m}()), so thanks for that too.

Full disclosure: the errors below were collected by an AI agent working on my real project. It ran the builds, patched vendor/ to get past each failure, and cut every case down to a minimal repro, which was then run against both PHP 8.5.6 and Manticore 0.18.0.

The build isn't through the front-end yet. So far it has needed about a dozen patches. Every repro below is valid PHP 8.5 and runs under php 8.5.6 with the output shown. None of them is listed in docs/differences.md or docs/gaps.md, and I couldn't find an open issue for any of them. I left out variable variables and $GLOBALS as a whole array, since those are documented gaps.

Environment: Manticore 0.18.0 (release tarball), macOS 27.0.1 arm64, Apple clang 21.0.0, PHP 8.5.6 as the oracle.


Bugs

1. #[\Override] is rejected when it implements an abstract method from a trait

<?php
trait LogsT { abstract public function log(string $m): void; public function info(string $m): void { $this->log($m); } }
interface Emitter { public function emit(): void; }
class NoopLogger implements Emitter {
    use LogsT;
    #[\Override] public function emit(): void {}
    #[\Override] public function log(string $m): void { echo "log: $m\n"; }
}
(new NoopLogger)->info("ok");
  • php 8.5: log: ok
  • manticore: compile failed: NoopLogger::log() has #[\Override] attribute, but no matching parent method exists at line 7

PHP counts an abstract trait method as the method being overridden. Seen in open-telemetry/api (OpenTelemetry\API\Logs\NoopLogger, which uses Psr\Log\LoggerTrait).

2. break(1); with parentheses does not parse

<?php
foreach ([1, 2, 3] as $i) { if ($i === 2) { break(1); } echo $i, "\n"; }
  • php 8.5: 1
  • manticore: parse failed: expected ';' after break at line 2, column 50

continue(n) has the same shape. Seen in mpdf/mpdf (Mpdf.php).

3. instanceof with a class name held in a static property

<?php
class Engine {}
class BigInteger {
    private static $mainEngine = Engine::class;
    public static function check($x): bool { return $x instanceof self::$mainEngine; }
}
var_dump(BigInteger::check(new Engine), BigInteger::check(new stdClass));
  • php 8.5: bool(true) bool(false)
  • manticore: expected ';' after return at line 5, column 67

Seen in phpseclib/phpseclib (Math/BigInteger.php).

4. Alternative switch (…): … endswitch; syntax

<?php
$m = 'card';
switch ($m):
    case 'card': echo "card\n"; break;
    default: echo "other\n";
endswitch;
  • php 8.5: card
  • manticore: expected '{' in switch body, followed by cascading errors

if:, foreach: and the other alternative forms compile. This one matters for Laravel in particular, because Blade compiles @switch into exactly this form. Any precompiled view that uses @switch fails (examples/laravel-app/aot/compile-views.php passes it through as is).

5. Assigning a static property through an instance ($obj::$prop = …)

<?php
class JWT { public static $leeway = 0; }
$jwt = new JWT();
if ($jwt::$leeway < 1) { $jwt::$leeway = 1; }
echo JWT::$leeway, "\n";
  • php 8.5: 1
  • manticore: MIR.lower: unsupported assign target kind DynamicStaticAccess at …:4

Reading $jwt::$leeway works. Only the assignment fails. Seen in google/apiclient (AccessToken/Verify.php).

6. static::$prop = … where only the subclasses declare the property

<?php
abstract class Key {
    public static function forceEngine($e) { static::$forcedEngine = $e; }
    public static function engine() { return static::$forcedEngine; }
}
class RSA extends Key { protected static $forcedEngine = null; }
RSA::forceEngine('PHP');
echo RSA::engine(), "\n";
  • php 8.5: PHP
  • manticore: MIR.lower: unsupported assign target kind StaticAccess at …:3

Late static binding resolves the property on the called class. Seen in phpseclib (Crypt/Common/AsymmetricKey.php, Crypt/Common/Formats/Keys/PKCS8.php).

7. if (false === function_exists('f')) is not folded, so the guarded function fails to lower

<?php
namespace DeepCopy;
if (false === function_exists('DeepCopy\deep_copy')) {
    function deep_copy($v) { return $v; }
}
echo deep_copy("ok"), "\n";
  • php 8.5: ok
  • manticore: MIR.lower: unsupported statement kind Function at line 4

The same code with if (!function_exists('DeepCopy\deep_copy')) compiles and runs. Seen in myclabs/deep-copy.

8. A guard on a class constant (Logger::API >= 3) is not folded

<?php
class Logger { const API = 3; }
if (Logger::API >= 3) {
    trait Compat { public function v() { return "v3"; } }
} else {
    trait Compat { public function v() { return "v2"; } }
}
class H { use Compat; }
echo (new H)->v(), "\n";
  • php 8.5: v3
  • manticore: MIR.lower: unsupported statement kind Class at line 6

This is the shape sentry/sentry uses to support Monolog 2 and 3 (Monolog/CompatibilityLogLevelTrait.php, CompatibilityProcessingHandlerTrait.php).

9. if (\false) is not folded, while if (false) is

<?php
class Real {}
if (\false) {
    class Legacy extends Real {}
}
echo "ok\n";
  • php 8.5: ok
  • manticore: MIR.lower: unsupported statement kind Class at line 4

With if (false) the same file compiles. The result is the same with and without a namespace. Seen in google/apiclient (src/aliases.php) and nikic/php-parser (the classmap-authoritative compatibility stubs, e.g. Node/Expr/ArrayItem.php).


Diagnostics

10. Several MIR.lower errors do not name the file

In a project with tens of thousands of files, these messages could not be located without writing my own scanners:

  • unsupported statement kind Function at line 4 (repro 7)
  • unsupported statement kind Class at line 6 (repros 8 and 9)

Under manticore build, the errors from repros 5 and 6 read at <source>:228 and at <source>:444. Under manticore compile they include the file name. Parse errors, by contrast, are excellent: path, line, column and a snippet.

11. Only the first error is reported, and each attempt is expensive

On this project, a -O 0 build reaches the failing lowering after about 3 minutes and 11–14 GB RSS (≈30 GB peak footprint), then stops at the first error. Finding the cases above took 15 full attempts. A mode that keeps going and lists every parse/lowering error in one pass would help a lot. The tolerant parser from #481 and the manifest-aware analysis in #489 look like the natural base for it.


Packaging

12. The macOS arm64 release binary links against Homebrew openssl@4

dyld: Library not loaded: /opt/homebrew/opt/openssl@4/lib/libssl.4.dylib
  Referenced from: ~/.manticore/bin/manticore

The README's requirements table says OpenSSL 3, and brew install … openssl@3 is the documented macOS command. On a machine that has only openssl@3, the 0.18.0 tarball does not start until brew install openssl@4 is run. Either link the release against openssl@3 or update the requirements and the install command.


Design feedback (not a bug)

13. Files that PHP never loads still abort the whole build

Composer packages often ship one class per supported version of a dependency and choose one at run time. Under PHP 8.5, the other variants are never loaded, so their signatures never get checked. Manticore compiles every file and stops at the first incompatible one:

src/LineFormatter.php   class LineFormatter { public function format(LogRecord $r): string { … } }
src/LegacyFormatter.php class LegacyFormatter extends LineFormatter { public function format(array $record) { … } }   // never loaded
src/main.php            echo (new LineFormatter)->format(new LogRecord), "\n";
compile failed: Declaration of LegacyFormatter::format(array $record) must be compatible with LineFormatter::format(LogRecord $r): string in …/LegacyFormatter.php

Real cases from this build: google/cloud-core (Logger/AppEngineFlexFormatter.php, the Monolog 1/2 variant, next to …V3.php) and psy/psysh (Readline/Hoa/FileLink.php).

I understand why a whole-program compiler checks everything. Unsupported functions already become run-time traps (undefined-function traps (N)), though. The same treatment could work for a class that cannot be declared: mark it as undeclarable and make the first new, static call or autoload of it fail at run time. Then a vendor file the program never touches would not block the build. A per-file exclude for Composer roots would also help: today the only way I found to drop code is the package-level composer.packages allow-list.

14. No Redis client extension

There is no Redis class (phpredis), so Laravel's redis driver cannot be used for cache, queues or sessions. To get this far I switched them to array/sync. Most production Laravel apps rely on Redis for all three, so this will probably be one of the first walls people hit after the build succeeds. A native Redis class on top of the existing socket layer, or documented support for predis/predis (pure PHP), would cover it.

Activity

  1. blacktrs commented on Nov 10, 2026

    @blacktrs
    Contributor

    Hi @EduardoMateos
    Thanks for the great report based on the real application.
    All findings are definitely useful for further development. Some gaps are known.
    Every step will be converted into an issue and then fixed in the next release.

    The compiler is still in an early phase regarding real-world applications; however, such reports allow for faster progress and the early resolution of any discrepancies with standard PHP.

  2. blacktrs commented on Nov 10, 2026

    @blacktrs
    Contributor

    Tracking, one issue per item:

    Bugs

    Diagnostics

    Packaging

    Design / features

    Items 4, 5, 7 and 9 already pass on a pending branch; they land with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions