I’m working on a new project that is going to make heavy use of different AJAX calls to PHP. Is it proper to create one file that contains all the different functions and use a case statement to pick the proper one, or should I create a php folder and put each function in its own file?
I’m trying to get my skills back on track with modern web design standards and practices, and in the past, one file to rule them all was the way to go for simplicity sake; however, so much has changed that I wanted to ask before I got 10,000 lines into this project.
Thank you for any advice you can provide.
Instead of thinking about the implementation of the problem why not think about the interface?
This is what I mean, you could separate the real work to done in classes somewhere, and let the ajax make calls to another separate classes/function. Then the functions called through ajax can query the different classes/objects to accomplish the work and send respond back to ajax. It may sound like the MVC pattern. The advantage of this is clearly code reusability , improved decoupling and easier code maintenance.
Example:
And function called through ajax could be
Hope you get my point!