During our work as a web developer for a meteorological company, we again and again face the same task: We get files somewhere (FTP / Web / directory / mail) and import the data contained in the database.
Of course, the file format is never the same, databases are always developed differently, countless special cases need to be handled, etc. etc.
So now I am planning an importing structure for this kind of work. Since we are all experienced PHP developers, and the current scripts are PHP or Perl, we will stick with PHP as a scripting language.
- The data receiver will extract the file from the source, open it and save the contents in a string variable. (Don’t worry, PHP will get enough memory from us.)
- The data handler will do the hard work of converting the string to some sort of array.
- The array will be stored in the database or written to a new file, or whatever we do with it.
Along with this functionality, some common error handling, logging, and email reporting will be performed.
The idea is to use a set of classes (some getter classes, many specialized handlers, some writer classes).
My question is: How can I organize these classes in a working script? Am I coming up with some kind of metalanguage that will be interpreted and the classes are named accordingly? Or just provide some simple interfaces these classes should execute, and my users (like I said: experienced PHP developers) will write small PHP scripts loading these classes?
The second version almost certainly offers the greatest flexibility and extensibility.
Do you have any other ideas regarding such an undertaking?
source
share