I am currently working on symfony2 framework. I want the html data that twig file renders in one file.
My code:
$myfile = fopen("somefile.html", "w");
$data = $this->render("somefile.html.twig");
fwrite($myfile, $data);
This works fine but in addition with html data I get the following line
"HTTP/1.0 200 OK
Cache-Control: no-cache
Date: Tue, 02 Jun 2015 07:50:16 GMT"
as a staring lines I want to remove them is it possible via symfony or I have use regex?
Try to use renderView() instead of render().
$myfile = fopen("somefile.html", "w");
$data = $this->renderView("somefile.html.twig");
fwrite($myfile, $data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With