发布于 2015-08-27 16:22:48 | 283 次阅读 | 评论: 0 | 来源: 网络整理
The Symfony framework is well-known for being really flexible and is used to build micro-sites, enterprise applications that handle billions of connections and even as the basis for other frameworks. Since its release in July 2011, the community has learned a lot about what’s possible and how to do things best.
These community resources - like blog posts or presentations - have created an unofficial set of recommendations for developing Symfony applications. Unfortunately, a lot of these recommendations are unneeded for web applications. Much of the time, they unnecessarily overcomplicate things and don’t follow the original pragmatic philosophy of Symfony.
This guide aims to fix that by describing the best practices for developing web apps with the Symfony full-stack framework. These are best practices that fit the philosophy of the framework as envisioned by its original creator Fabien Potencier.
注解
Best practice is a noun that means “a well defined procedure that is known to produce near-optimum results”. And that’s exactly what this guide aims to provide. Even if you don’t agree with every recommendation, we believe these will help you build great applications with less complexity.
This guide is specially suited for:
For other situations, this guide might be a good starting point that you can then extend and fit to your specific needs:
We know that old habits die hard and some of you will be shocked by some of these best practices. But by following these, you’ll be able to develop apps faster, with less complexity and with the same or even higher quality. It’s also a moving target that will continue to improve.
Keep in mind that these are optional recommendations that you and your team may or may not follow to develop Symfony applications. If you want to continue using your own best practices and methodologies, you can of course do it. Symfony is flexible enough to adapt to your needs. That will never change.
Any Symfony developer, whether you are an expert or a newcomer, can read this guide. But since this isn’t a tutorial, you’ll need some basic knowledge of Symfony to follow everything. If you are totally new to Symfony, welcome! Start with The Quick Tour tutorial first.
We’ve deliberately kept this guide short. We won’t repeat explanations that you can find in the vast Symfony documentation, like discussions about dependency injection or front controllers. We’ll solely focus on explaining how to do what you already know.
In addition to this guide, you’ll find a sample application developed with all these best practices in mind. The application is a simple blog engine, because that will allow us to focus on the Symfony concepts and features without getting buried in difficult details.
Instead of developing the application step by step in this guide, you’ll find selected snippets of code through the chapters. Please refer to the last chapter of this guide to find more details about this application and the instructions to install it.
After reading this handbook, some of you may be considering refactoring your existing Symfony applications. Our recommendation is sound and clear: you should not refactor your existing applications to comply with these best practices. The reasons for not doing it are various: