Liam Hammett has opened discussion on an RFC proposing Native Markup Expressions, a feature that adds JSX-inspired syntax for HTML fragments directly into PHP.

The proposal introduces a compact syntax for defining and composing HTML markup as language expressions. Lowercase tag names represent literal HTML elements, while capitalized tag names, namespace separators, or static method references denote components. All embedded expressions are escaped by default for security.

A `<button class="btn">Sign in</button>` expression compiles to `new \Markup\Element('button', ['class' => 'btn'], ['Sign in'])` at compile time. This means markup meaning is determined during compilation, not at runtime. Components implementing the `Markup\Html` interface can be invoked like `<Greeting name="Rasmus" />` and automatically render their return value.

A working implementation with tests is available in pull request php/php-src#22661.

Key design decisions under discussion include the capitalization heuristic for distinguishing components from HTML elements. Garrett W. questioned whether this approach—borrowed from JavaScript's JSX, where lowercase means HTML and capitalized means component—is appropriate for PHP, given that PSR-4 is not a binding standard and lowercase class names are legal. Liam responded that the heuristic prevents silent bugs from typos, allows compile-time resolution without autoloader overhead, and provides a performance benefit for the common case of mostly HTML with sprinkled components.

Other discussants, including Edmond Dantes, suggested PHP could benefit from generalized parser hooks enabling extensions to define custom DSL syntaxes rather than locking in a single markup syntax. Edmond noted that such extensibility could enable SQL-like LINQ expressions and attribute-based metaprogramming patterns. Liam acknowledged these are separate considerations from the current RFC scope.