I started like that too, a page for each action - for about a week.
Its simple to work on, but boy, how many pages you end up with!
So, for years I made monster pages using page controllers like this
PHP Code:
//include files here e.g.
include("shared_header.php");
if( $_POST['saveSubmit']){
//monster block of code
}
if( $someothevar is set ..... ) {
// you get the picture
}
Now while debugging was a nightmare, with a code editor that understands code folding and brace matching, it was quite bearable. I page = 1 mini app at least you knew which file to look at if there was a problem.
Using that system I then slowly started moving more and more code out of the page into include files - sharing a header and footer for example is quite easy.
Then as you suggest - I started to discover OOP, and moved even more logic off the monster pages into testable, re-usable classes.
Then I found out about "layers" and started moving all my "business logic"
into there own files, y'know all the sql stuff basically.
This is when it all started to make sense. Now the bit I never really 'got' was templates for your views. I dont like them - and I think PHP is a good enough template engine.
So I'd say to you, if you can try and encapsulate your sql statements into their own functions first, move them into their own files, their own folders even - out of the public html tree, and include them as and when you need them. Work from there. I wish I had done that first.
Hope that helps you.
Bookmarks