I'm trying to parse a file into an array but not sure currently how that may be done.
I'm used to using something such as Guzzle to get a request and into a json/xml response and then process the data from there.
The source of this data does not have any API available only a downloadable file in XML or CSV.
What would be a common method of handling files with data? Do I need to store it in a directory? Upload it to a web host online? Not sure how to go about it just yet.
@RachidLaasri In basic terms yeah I guess that's the idea.
Let me provide more clarity.
So I believe if I was to do this without Laravel it would need to either have a frontend form attach/upload file field then on the backend read it with something like xmlreader and lastly parse it with simplexml and then I can iterate through it and either use in an array and/or dump what I need into MySql and be done with it.
Is Guzzle only for mainly rest/soap getting of data into xml/json? I'm familar with using it for that purpose.
My XML data file will need to be download manually by me as the source doesn't provide it through rest/soap api.
So using your example would I simply store it at a location whether locally or on a server somewhere and this parser would then just parse this XML then allowing me at that point to use the data as I see fit?
$guzzleClient = new Client();
$response = $guzzleClient->get('YOUR_SOURCE_URL');
$body = $response->getBody();
$body->seek(0);
$size = $body->getSize();
$file = $body->read($size);
File::put('STORAGE_PATH', $file);
// Then you can do stuff with your file locally on your server
$xml = $reader->load('STORAGE_PATH');