I'm working on a project that requires from me to make modular and extendible code structure. This code should be able to support multiple clients. The good news is that code should not do anything spectacular. I will explain this in more details later in the question.
So now I have around 30 branches for about 60 clients. Some clients needed their own branch because at the time it was easier to just separate their code from everyone else’s so that over time grow to 30 separated codes, that are very very similar.
So now architecture could not be more simpler. Request comes from client in XML form and then I process I return XML. Process part is mostly CRUD. Nothing fancy. I have two front controllers one for actions (INSERT, UPDATE, DELETE) and one for requests(SELECT). Then that front controller just includes script that client requested. Every request and every action has their own dedicated script. There are not a single class in the project. Everything is written in procedural way.
So in the new App structure the goal is to have one main branch that will all clients use and it will be managed from conf file.
I'm telling you all this because I'm not sure how to structure everything. I don't have much experience with OOP I know the concepts and theory but its harder when it comes to actual coding in that style.
My idea now is. I'm leaving two front controller for action and request because that doesn't require any change from client-side of application and that is important for now. They will now serve as only get request and echo it back. They will also call ActionController and RequestController. They will be a little smarter. They will know how to recognize which request/action client sent and then they will make new object of that class.
Every action/request has some steps that it needs to do. So i'm thinking that every class need some public method 'execute' that will just call method of that class by the order that it needs to, but I'm afraid that, that is also procedural way of thinking just it wont be in global score but in Class.
$client_request = new $fullClassPath(new $mapperClassPath); $response = $client_request->execute($request);
Also How to handle Database, I probably should make actions on database as abstract as possible.
Configuration file will be very important, so I don't know if it's the solution to make class for every feature and include classes if that feature field is set to true in config file?
Every action has its own response to client and it can be pretty heavy xml. What is the solution there. Should I have a Response class that will handle that. Im afraid that the class will be pretty heavy because there are around 20 actions and 5 requests and everyone have different xml response.
So every help is appreciated with someone who had experience with similar projects, some links on good articles also wouldn’t hurt.
I should mention that language I’m working with is vanilla(plain) PHP.