How to properly build a PHP website?

Where and in which order to put the code?

&nbsp

MaxGrenk

11:19 pm on Apr 27, 2011 (gmt 0)

This is more so a fundamental question... I started rewriting my ASP content mgmt system in PHP earlier this year... and as one would guess and hoe, I came across a lot of things I could do better these days. Utilising PHP provides different solutions to problems.

[I am quite shocked and amazed about what I managed to build over the past 10 years in 7,100 lines of code, some of it has grown like a cancer and other bits are quite nice.]

Now that I have almost finished the rewrite, with lots of reflecting, I started wondering about the question: What is the proper way to build a non-shopping web site?

I am not after code, but a logical (best practice, or most effective) flow and arrangement.

Is there a point in handling all rewrite rules (hotlink protection, image serve from different directory, old->new link redirects in PHP code, or split these functions to .htaccess and PHP code? Following that, where to put what?

Is there a good book out there going through all these steps? Other sources?

MaxGrenk

12:03 am on Apr 28, 2011 (gmt 0)

I did some further research on the 'unknown' drivers for my questions... It looks like my intensive occupation with coding has led to the fundamental questions of software design, such as coupling, cohesion and decomposition of a system into modules.

The rewrite gave me the bigger picture, the issues surrounding code maintenance, etc.

Maybe there is no answer to my question, except to understand software design better, which would then led to the proper assembly of code components to form a better larger system.

coopster

3:05 pm on Apr 28, 2011 (gmt 0)

Valid question.

The web developer tool set is much more than code. Knowing which component handles which area best is part of the overall analysis, design and development process. For example, logging and tracking. Logging and tracking HTTP requests are handled quite well by the underlying HTTP server itself. You can push as much data as you like into the log files and forward them to a post-processing script that runs on your server too. Also, perhaps you want to grab HTML <form> requests and log/track them. If so, you can use your server-side PHP application to write the information to a database table, system file, and/or email yourself with failures or possible hack attempts.

g1smd

3:12 pm on Apr 28, 2011 (gmt 0)

I have written a whole page of related info dotted throughout this thread... [webmasterworld.com...]