During our work as web developer for a meteorological company, we are faced with the same task over and over again: Get some files from somewhere (FTP/Web/directory/mail) and import the contained data to a database.
Of course the file format is never the same, the databases are always designed differently, countless special cases have to be handled, etc, etc.
So now I'm planning an importing framework for exactly this kind of work. Since we're all experienced PHP developers and the current scripts are either PHP or Perl, we'll stick with PHP as scripting language.
- A data getter will fetch the file from the source, open it and store the content into a string variable. (Don't worry, PHP will get enough memory from us.)
- The data handler will do the complicated work to convert the string into some kind of array.
- The array will be saved to the database or written to a new file or whatever we're supposed to do with it.
Along with this functionality there will be some common error handling, log writing and email reporting.
The idea is to use a collection of classes (Some getter-classes, a lot of specialised handlers, some writer classes).
My question: How do I practically organize these classes in a working script? Do I invent some kind of meta language which will be interpreted and the the classes are called accordingly? Or just provide some simple interfaces these classes have to implement and the my users (like I said: Experienced PHP developers) will write small PHP scripts loading these classes?
The second version almost certainly offers the biggest flexiblity and extensibility.
Do you have any other ideas concerning such an undertaking?