"View source" for the full stack
While browsing Hacker News (as one does) today I came across this PHP snippet, as highlighted by this comment.
<?php
if (isset($_GET['source'])) {
highlight_file(__FILE__);
exit;
}
When placed in a PHP script, it lets you pass a ?source
query parameter in the URL to see the complete, syntax-highlighted PHP program that's currently running. See https://lucb1e.com/randomprojects/php/funnip.php?source for an example.
This strikes me as the simplest implementation of a "View source" for the backend that I've seen, and I wonder if this kind of direct exposure of the full-stack source of a web app could be possible even for more complex applications. I remember Vercel (back when they were called Zeit) used to expose the full source of open-source JavaScript applications under a special URI path (I think /_src/
, but I'm not certain).