Brief introduction
Symfony2 is a PHP language-based Web development framework, with rapid development, high performance features. But Symfony2 's learning curve is also steep, inexperienced beginners often need some practice to master its characteristics.
This paper introduces some core functions and features of SYMFONY2 framework through an example of rapid development of a tracing platform. By reading this article, you can learn about the excellent features and technical features of the SYMFONY2 framework with specific examples to realize the advantage of using the SYMFONY2 framework to support rapid web development.
Suitable for people
This article is intended for readers who want to improve the development of the PHP language, or who are interested in the SYMFONY2 framework.
This article also applies to system architects and various technical decision makers.
1. Preface
A 7-magnitude earthquake occurred in Yaan region, Sichuan Province, China in the recent April 20, and the cumulative number of people affected reached more than 2 million. The missing platform in such circumstances can play a great help, and, the earlier the landing platform, the higher the practical value.
Symfony2 can be used to support the construction of large-scale web sites, in the rapid establishment and development of small and medium-sized websites also have very good support. I would like to take the opportunity of this article to give you a concrete share of how I developed a set of Web site support for the PFIF[^1] format within 3 hours based on Symfony2, hoping that readers would have some understanding of the various components and functions of Symfony2.
[^1]: People Finder interchange Format (wiki) is a widely used open data structure and standards that can be used to exchange tracing information between different organizations or websites after a disaster, helping those who lose contact find each other.
Use of 2.Bundle
One of the biggest features of the SYMFONY2 framework and related communities is the support bundle. What is bundle? In simple terms, bundles are an abstraction of a "function". By abstracting a specific type of problem into a bundle, the logic of a system can be segmented: the bundle developer can focus on solving some sort of problem, and the user of the bundle can focus their work on their business logic.
In the field of Internet development, there are a lot of functions that can be abstracted. such as user login system, such as news commentary, such as Js/css file compression and merging and so on. To give a specific example, such as user login system, most of the projects for the user system needs are almost the same, but every time to develop new products, will be more or less to re-create a whole or a part of the user system wheel. The emergence of a bundle that is dedicated to managing user systems will relieve the development pressure on these projects, improve project quality and speed up overall project development.
Symfony2 also supports bundles. The Symfony2 community has a lot of community-maintained bundles, and using these open-source bundles allows our project to directly have the functionality that part of the bundle provides.
The following is a list of some of the third-party bundles used in this project, as well as the corresponding responsible tasks.
| Bundle Name |
Function Introduction |
responsibilities in the project |
| Mopabootstrapbundle |
Provides bootstrap-based page structure and templates |
Provides a basic HTML schema for the page, style |
| Nelmioapidocbundle |
Documentation and interface testing tools for automated API generation |
Generate API documentation and interface test tools, and allow engineers and third-party callers to test the interface properly using tools |
| Jmsserializerbundle |
Object for serialization Tool |
In the interface, convert the entity object generated by DOCTRINE2 to JSON format |
A bundle needs to be installed, usually in two steps:
Install these bundles using composer
Configure Symfony2, turn on support for these bundles, and do some setup work.
Most bundles can be integrated into your project through the above two steps, and installing these bundles only requires modifying some configuration files and running a system command.
Source: http://www.bianceng.cn/webkf/PHP/201309/37273.htm
Use Symfony 2 to develop a tracing platform within three hours