Laravel's debug mode [has a big warning in the docs about this](https://laravel.com/docs/9.x/configuration#debug-mode), defaults to off, and newer versions of Laravel use a different error module that doesn't show env vars.
It's still a footgun. It's pretty clear that this shouldn't be done, so why allow it this easily?
In prod it should emit a log message saying "you cannot do that. if you really, need to follow these steps: <something cumbersome like placing a file somewhere with some dedicated end date for debug mode, or scoping rules>"