I have a controller that generates a custom 500 page. I have set up a route at the path: '/500'. I would like to capture this as HTML and save as a static file, so that I don't need to bootstrap Drupal and run that controller when I return a custom 500 page.
I have been using this code:
$contents = file_get_contents($base_url . "/500");
This works for me locally, but we have a lot of restrictions on our QA site so that file_get_contents is blocked.
Is there another way to render the entire page that this controller would return? For example, with the render service?
Also, I would want it in a logged-out context. I wouldn't want the admin toolbars, etc. to show up.
I found some code about subroutines. Is that a good way? I'm sure there's a way to use the Drupal render service to render a render array with the entire page. That sounds maybe the best way to do this?
Does anyone know how I might render the entire page programmatically?
I'm thinking in order to render the metadata and page classes based on a route, you're pretty much required to make a request.
There is another question about rendering parts of the page, but not the entire page.