Big PHP/MySQL project - some pointers ?

Associate
Joined
3 Mar 2004
Posts
1,312
Location
West London
Hi,

I've googled and checked up a lot of articles on PHP (I used it a bit at university but nothing for making a fully fledged site) and was just wondering what standards people adhere to here?

What I mean is, if your site has multiple tables, do you create PHP classes with functions for each of those tables for example? I write Java EJB code on a daily basis and now I can't see logically why I'd want to just have a scrap of code to say, insert a new user in the page where I want it (signup.php), rather than say having a class for the user table and having all related calls to this table in there?

So I'd have a user php class with all the functions such as sign_up/log_in/log_out etc. Then I'd do the same for say the 'user posts' table. I guess this all sounds very basic but is this how people go about writing their PHP code?

Also, with regards to accessing the database, do people connect in each function and then drop the connection or is there some standard way to do? I'm just a bit confused with what direction to take if making a large scale site...
 
Honestly? Must developers do there own thing. There isn't really a universal way of doing things unless you're using a framework. Even then people do things differently.

Ah I see. I've looked up stuff like using templates/framesworks - this I don't intend to do, and maybe the thread title is a bit misleading, its not a 'BIG' big project, just a personal mini-project but I want to do everything correctly and it's just a bit confusing after reading so many different things!
 
This is wrong.

For a big application, I recommend picking up a book on PHP design patterns. If you're used to your Java patterns, beans and what not then these will come naturally to you. However, they are a must in large-scal PHP development; it is not as easy to get PHP to scale as it is with Java.

Just remember;
1) Don't tightly couple your classes and functions to their data and function - keep it generic
2) Use objects, and never ever detract from using objects

Thanks :)

With regards to 'all coders' do their own thing - the thing is I wanted to learn best practise should I ever get a job that involved php and/or wanted to add that to my CV as another skill set I had.
 
Back
Top Bottom