Hi On 2026-09-22 15:17, Tim Düsterhus wrote:
My current PR automatically executes any `Closure` returned by the main PHP script, such that:
Based on the replies it has become clear that the proposed Closure approach has several questions to solve and possibly needs prior design (e.g. defining a request or context object that would be passed as a parameter) to not paint ourselves into a corner. This requires much more thought than I'm willing to spend right now, given I wanted to solve a specific use case of mine.
I'm therefore abandoning the Closure idea and will instead look into …
Another possible solution, that I didn't yet evaluate, might be defining a magic constant `__MAIN__` that is equivalent to `__FILE__` of the script that is executed first.
… defining a __MAIN__ constant, which should hopefully have much fewer design considerations and might also benefit PHP applications that don't leverage the front-controller approach to protect internal files from direct access (e.g. as a native variant of phpBB’s IN_PHPBB constant).
Best regards Tim Düsterhus
