I've been thrown head-first into a new job developing web applications in PHP. I'm by no means new to PHP, but I haven't developed large-scale applications before. I'm wondering how to structure my development to avoid setting myself up for problems in the future. How do I design and architect my applications in a sound way that allows them to scale over time in terms of functionality and performance. I'm thinking of things like:

Separating back end from front end

Directory structures

I would appreciate pointers to architectural and application design patterns, frameworks and methods that allow me to approach large-scale PHP web application development in a sustainable way.

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
If this question can be reworded to fit the rules in the help center, please edit the question.

Hi! The most common architecture for web applications is MVC, for PHP and every other popular web platform. That said, you should read our FAQ. Although software architecture is on topic, you need to revise the question to be a bit more specific. A "healthy discussion going about general architecture" doesn't fit the Q&A format of the site.
–
Yannis Rizos♦Jan 28 '12 at 15:47

I am a frequent visitor to the S/E Sites, I had a feeling there would be no one answer to this question however, hence the "discussion" comment. Thanks for the MVC pointer though :)
–
Brad MorrisJan 28 '12 at 16:15

3 Answers
3

A rough diagram of the architecture of the latest large scale project I was involved in.

It's only a basic outline, adapted from the actual architecture documents and presented in a way that resembles a typical n-tier approach combined with a typical MVC approach. As you can see the logic and data tiers are connected via a service layer, and more specifically a REST API, that was inspired by Recess, a lesser known PHP framework.

The behemoth of PHP frameworks, with an impressively well written codebase and extensive list of features. On large scale applications you'll find yourself tweaking the framework more often than not, and I find ZF's codebase the most pleasant to work with. But beware, it's not an entry level framework.

Kohana started out as a fork of CodeIgniter, and that was reason enough for me not to use it, initially. Nowadays it has grown into a solid and elegant framework that differentiates itself from every other by following an Hierarchical MVC approach. HMVC allows for a greater extend of modularization than MVC. For the project in the diagram I adapted Kohana's HMVC to ZF, but I've started using Kohana for smaller projects and considering it for larger as well.

All that said, the important thing to remember is that larger applications usually have unique challenges. You should evaluate every popular third party solution there is, and you will probably gain a lot from a couple of obscure ones. When I first evaluated Recess it was far from production ready but its approach essentially made it into the project.

Lot's of good stuff in there, but for a quick overview you should start with the top ten list. And research PHP solutions for those common vulnerabilities.

Stack vulnerabilities

A good habit is to periodically monitor PHP's open bugs. Even if you are no expert yourself, there are almost always workaround tips on security threats. And of course, you should extend the habit to every other part of the stack, especially the most vulnerable ones, like the web server and the database.

Actually Yannis, I've got a question for you. I've recently grown very interested with PHP. I've been trying to learn it myself, but I'm having a bit of trouble. It also seems you're pretty good with PHP yourself :-). Would you mind sharing a bit of guidance? If so, I'll create a chat room.
–
DynamicJan 28 '12 at 23:28

Thats exactly the sort of answer I was looking for! Its a hell of a lot of info to take in, I think ill have to do some absorbing and tinkering over the next hour but you've given me somewhere to start. Thanks :)
–
Brad MorrisJan 28 '12 at 23:41

I've been working around PHP for a few years now. Altough I agree with Yannis that this question is somehow open, I think I'd be giving you a few pointers. First, as Yannis said, yu should look into MVC, to do so, the two frameworks I can recommend are CodeIgniter and Symfony. The first one is lightweight and very easy to get started with, however, you might just need to add some extra customizations to get a nice setup working, will get into that soon. Symfony is a project started by Fabien Potencier that uses many of the design patterns in software engineering, however, the learning curve is much steeper than CodeIgniter's.

Finally, you should look into a templating framework, like Smarty, Dwoo or Twigg. Smarty is the oldest and hence the most stable. Dwooinherits from Smarty and adds a thing or two to support OOP better on PHP 5. Finally Twigg is the templating alternative provided the Symfony team, I haven't see it myself but if it comes from the Symfony teamit should be nice.