Answer the question
In order to leave comments, you need to log in
What is the way to do PARSER in Symfony?
Good afternoon.
Recently started working with Symfony.
And the task arose to write your own XML-parser.
those. there is an XML file of the order weighing 200 mb with more than 40 thousand records.
Parsing such a file takes a certain amount of time.
That is, it loops through all the lines of the file, and so on.
And the essence of the question is what method can parse a file in the background?
Keyword in background.
those. we take uploading a file, it redirects us to the main page (for example) and shows a window in the process of uploading / parsing a file.
Thanks in advance.
If it's not difficult to describe a little the process of how to do it.
Answer the question
In order to leave comments, you need to log in
Large files are parsed in streaming mode. For XML, there is a stream parsing standard - SAX . PHP has a standard module that implements SAX via libxml2 .
To implement background processing, there can be many different approaches depending on your application: this is the banal launch of tasks by cron, queuing, etc., there is a lot of information on this issue.
If you need information about progress, then obviously you will need some kind of communication channel between the background processing process, the server and the client. Again, there can be many implementation options, in addition, your desire to show progress as a whole casts doubt on the need for background processing for you.
I also want to note that parsing 200mb XML is not a task that requires progress to be displayed. the parsing process itself will take a maximum of a few seconds, but rather even faster. It may take more time to load this file, or save / process data received from XML, perhaps this is what you mean?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question