In my controller I have the following with $registration_data coming from the database and the xml.index view containing my xml file contents after looping through the $registration_data and creating the XML nodes, etc...
$file_contents = View::make('xml.index', $registration_data);
$response = Response::make($file_contents, 200)->header('Content-Type', 'application/xml');
I want to then write the $response view to a file so I can use SSH:into() to upload the file to a server. How can I get the contents of the view into a file to do this?
I can see the xml response in the browser just fine btw.
Use File::put('file.xml', $file_contents)
which is basically a wrapper for PHP's file_put_contents()
. Also you need to call the render()
method on the view to get the content as string.
$content = View::make('xml.index', $data)->render();
File::put(storage_path().'/file.xml', $content);
return Response::make($content, 200)->header('Content-Type', 'application/xml');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community