PHP Best Practices: Creating a Blueprint for PHP Applications
The Meaning of Life
What is the one true path to creating a successful PHP application? Does it exist? Does everyone know what it is? What dangers should I avoid? What works, what doesn’t? Is there a guide that will lead me down this path?
You may find the answer to these questions if you scour the net, know what you are looking for, and know who is right and who is wrong, or proven and unproven if you want to look at it another way. You may also find a web of entanglement mixing old and new information with many different versions of PHP and related products. You may also come up empty handed with no clear picture to be your guide.
We can do better. We can develop a solid mental picture of what ingredients make a safe, scalable, performant, and realistic PHP application. We can write the cookbook for PHP web applications covering the topic from corner to corner providing:
- A sketch of typical web application architecture.
- A roughed-in application to act as a application kernel.
- A reference application based on the sketch and kernel application proving the goals are met.
Blueprints
Over a series of many articles, the Developer Zone will flesh out this “Blueprint for PHP Applications” and see what we can do with modern PHP, the Zend Framework, and other resources available to PHP developers. Early in the series, we will bring forward topics covering architectural areas of web applications to discuss with the community who can provide thoughts about what they feel is important for each, lessons learned, and best practices found. Later articles will bring the three deliverables into focus: the sketch as the mental picture of what an application looks like, a base application that can be used as a running sample or starting point for custom creations, and a reference application showing the full scope of the blueprint in action.
The blueprint is not meant to become a platform, an overly large application server, a framework replacement, a huge pile of XML configuration files, a CMS, or a plugin model for application building. It will be a delicate balancing act to provide guidance, best practices and a bit of proving code, while avoiding becoming a framework in itself.
What is a PHP Application?
This wouldn’t be a grandiose article without asking a really big question up front, well, besides the “meaning of life” question I opened with. Regardless, it needs asking as it sets the tone for future work; so here goes: What is a PHP Application? What is in scope of our blueprint building effort?
This sounds like a brainstorming question if I’ve ever heard one, so out comes the mind mapping tool. Here are the results of the initial brainstorming:
Given the rules of brainstorming, “every idea should be recorded and you can sort the mess out later,” I decided to not dwell too long on what perfectly fits or doesn’t, and instead get it into your hands for comment. You could argue that some items should or should not appear on the diagram, that some need further explanation, that you have additions to make and statements to be heard. I fully expect that you will do so and look forward to your comments (posted below).
Getting Started
In the meantime, it is clear that some core items from the brainstorming will survive regardless of any amounts of discussion. These will become the first few parts of the series, to explore each, draw out ideas and start developing the best practices for the architecture and application kernel. We can also begin the accompanying architecture diagrams for both the global view of the entire application, and the more narrow diagrams of the participating components. So let’s get started…
Coming up, Blueprint for PHP Applications: Cornerstone covering the principles of the blueprints, philosophical goals, concrete goals, and the breakdown of the major focus areas.


Comments
First, I could change "database" branch into something more general and name it e.g. datasource. Majority of web applications do use databases as their main datasource, but we should mention about the ones that use e.g. web services, XML documents or even flat files. Next, there could be a branch for accessibility and usability. Those terms do not have much to do with the PHP directly, but good web developers should have them in mind during their everyday work.
P.S. I won't write that the idea of Zend Developer Zone, PHP Best Practices, etc. is great idea because it's obvious it is. ;)
Escobar_one,
Thanks for the additional brainstorming. I updated the diagram to capture your comments. Those are all key areas to consider and it is great to have them in early as they tend to be pushed back in projects until it is too late for them to have the right level of impact.
Also, thanks for the support of this effort.—Jayson
this article series seems to become very interesting. Maybe I am lacking a bit of understanding, but what about the features a website offers for the users? I think these features should be added to the mindmap as well.
Examples would be:
- discussion forum / board
- weblog
- link catalogue
- picture gallery
- guestbook
- online shop
- etc.
Or are these kind of features to much high-level for the first mind mapping brainstorming?
Looking forward for the next articles.
Regards,
Ralf
Hello Ralf,
Good points, but web site features are not in scope for the blueprints. However, we will have a parallel track in cookbooks for features like you just mentioned. For example, to implement metadata tagging we would cover the typical database schema, indexes, queries, model, presentation layer, optimizations and caching, and anything else it needs to work successfully. So watch for that on another track.
Generation:
* Image
* Pdf
And some "mail" functionality could also be added?
PS: The registration feature on this website is asking for a telephone number, although it doesn't provide an input.
As others have said - this is not about a guestbook, polls, shopping cart, etc - it is about the CORE of your application. Each of these pieces will be used to create a functioning guestbook, poll, shopping cart - but the blueprint doesn't define those. Thats a whole other blueprint. hehe.
Yes, it seems there is alot to swallow here - and there may be some things I would prune from the blueprint, simply because the application doesn't require it and never will. Thats just the nature of differing applications. You might say they would need to be built in for scalability, but I am all about keeping it simple with just what is needed to get the application running smoothly.
This is a great topic!
Peace,
Nate
I think these features should be added to the mindmap as well.