\Response::make
expects you to pass a string with the content you want to return, but you are passing an object: simplexml_load_file
returns a SimpleXMLElement
instance.
As it happens, a SimpleXMLElement
can be converted to a string, but it won't return the full XML, just the content of that element - it's so that you can do things like $xml = simplexml_load_string('<doc><message>Hello, World!</message></doc>); $message = (string)$xml->message;
If you just want the full contents of the XML file, without any changes, you don't need to parse it with SimpleXML at all, just load the contents into a string:
$xml_string = file_get_contents(storage_path('app\file.xml'));
return \Response::make($xml_string , '200')->header('Content-Type', 'text/xml');
If the idea is that you'll be manipulating it later, so you want the object, then you need to call ->asXML()
to turn it back into a string:
$xml = simplexml_load_file(storage_path('app\file.xml'));
#TODO: Do something interesting with $xml
$xml_string = $xml->asXML();
return \Response::make($xml_string , '200')->header('Content-Type', 'text/xml');