I often read developers flaming about which PHP framework is the best for high traffic webshops. Scalable systems have several factors, and they should be analyzed separately even if they make up a single one at the end of the day.
Existing Or Custom Framework?
Obviously an existing one. I have authored a PHP MVC Framework, and it was a lot of fun for learning. There are still live sites running on it, but as most dev folks state it, it’s only good for gaining experience. If you’re doing it alone, you’ll never be able to compete with systems used by hundreds of thousands and developed by dozens. My experience was that I’m neither smarter nor have the time necessary — so my super framework has always been half-done. Nonetheless, you can learn a lot just by using an existing one.
Which PHP Framework?
It depends. I have worked with these already (chronological order):
- Symfony 1: was a nice one, lifespan is over, forget it for new projects (Symfony 2 is its successor, but they have actually nothing in common)
- Zend Framework 1: Used to be among the first ones, but it’s deprecated. (Magento 1.x is built on top of it btw.)
- CodeIgniter: Was an early bird as well. Avoid it. They’re still not using namespaces and apparently don’t give a shit about basic PSRs that are prevalent in the contemporary PHP world.
- Yii 1: another oldie, was fast, now it’s deprecated. (I’ve seen YII2 as well but haven’t been working with it)
- Symfony 2/3: One of the bests if not the best, but it’s a bit chunky and requires an experienced developer.
- Phalcon: It is written in C language (Zephyr — whatever) so it’s freakin’ fast. I like it a lot due to its simplicity and flexibility but its documentation is kinda crappy compared to the major competitors, and the entire system is generally less comprehensive.
- Laravel: The people’s framework. And is incredibly cool in the details. Fast enough. Its documentation is good, and if you consider Laracasts then Laravel’s docs are unbeatable. There are lots of extensions (similar to Symfony) available. But if you’re experienced enough, you’ll might be pouting about it.
It’s incredibly important to answer yourself the question: How many users do you want to scale your system for? Simultaneously 500, 1000, 2000, 5000, 10000, 50000, …? It’s an essential matter whether it’s a real demand or just a nice to have feature. Another important factor is that — even if it sounds weird — your framework of choice can only be a bottleneck at a low number of users. Why? Because no framework can help when you have simultaneously 10.000 users* (at least not in the PHP world). Real performance is provided by the appropriate architecture/infrastructure. This consists of multiple parts.
Performance And The Code
The most important is not to have something stupid in the code, especially not to execute too many SQL queries. Things like a loop or memory optimization or algorithm sharpening — that many developers think is magic — don’t matter too much at this level. Obviously, I’m talking about a mature codebase, written at least by middle-level developers. The essence of tuning for high traffic is exactly to unburden the application so that just a very percentage of the requests will reach your code.
Performance And Web Server
It is generally a good idea to use FPM for PHP since they run separately. Numbers are important here as well, depending on the number of CPU cores, RAM, etc. There are a lots of articles available, just google it and get your hands dirty.
If still a custom system, then I think the framework should be chosen based on which one fits your level of knowledge and your coding style. The framework primarily should serve your needs from the code maintainability perspective. If you’re experienced and/or educated enough, there’s a high chance you’ll use Symfony. But then, you already know all this 🙂
But in case you’re not, I recommend Laravel. It’s a modern, solid, unitary concept with well-tried patterns, great docs, videos(!) and community. Most important components already exists.
Of course, you have to check out all of them and pick the one you like.