Re: Automatically execute Closures returned from primary script
| From: | Tim Düsterhus | Date: | Wed, 23 Sep 2026 13:50:15 +0000 |
| Subject: | Re: Automatically execute Closures returned from primary script | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132605@lists.php.net to get a copy of this message | ||
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… 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__MAIN__that is equivalent to__FILE__of the script that is executed first.