I built and maintained a collection of open source libraries which brought preprocessor macros to the PHP landscape. This meant that folks could build and use custom syntax in their PHP projects, without compiling custom versions of PHP or installing extensions.
These repositories showcased syntax borrowed from a number of languages to achieve:
-
React-like PHP-in-HTML code (I wrote about how this worked, and how it could support a similar experience to Livewire)
-
Short closures with captured variable scope
-
Property loaders, for binding method calls and
new Classvalues to properties, which would resolve on construction -
Deferred operations, to execute code on unload
-
Parameter loaders, for binding method calls and
new Classvalues as default function arguments. -
Trailing commas in function definitions
-
Optional catch type definitions, so the types can be omitted when they don't matter
-
Object dereferencing and autoboxing that mirrors the DX of JavaScript
Many of these have since landed in the PHP language. I even designed a Docker based, online environment to write custom macros in, and showcase the existing macros.
The demo and documentation website is offline. I maintained Pre from the beginning of 2017 to mid 2021.
I had a lot of fun with this project, and presented a talk on the process of making and using various parts of the project, at LaraconEU.

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.