Symfony核心类概述,symfony核心概述
Symfony核心类概述,symfony核心概述
本文讲述了Symfony核心类。分享给大家供大家参考,具体如下:
Symfony的核心类
Symfony的MVC方式使用了一些你以后会经常碰到的类
1. sfController是控制器,他解码请求并专递至动作(action)
2. sfRequest存储了所有的请求元素(参数、Cookies、头信息等等)
3. sfResponse包含了响应头信息和内容,这些是最终要转换为HTML并送与用户的东西
4. 一个上下文(通过sfContext::getInstance()获取)保存了所有核心对象的参考和现有的配置信息,他可以在任何位置被访问。
就像你看到的,所有的symfony类使用sf前缀,这可以避免和你自己的类或变量冲突,而且可以使核心框架的类容易识别。
代码的组织
你已经知道了symfony应用的不同组成,但也许还不知道他是如何组织的。
项目结构:应用、模块和动作
在symfony里,一个项目是一组制定域名下的服务和操作,他们共享对象模型。
一个项目是由多个应用组成,一个应用有多个模块组成,一个模块可以包含多个动作。
项目结构图:
Symfony的根树结构及描述
apps/ |
包含了项目的应用,一个应用对应一个文件夹 |
Batch/ |
包含用于命令行执行或者调度的PHP代码 |
Cache/ |
缓存文件夹,需要777的权限 |
Config/ |
保存项目的基本配置 |
Data/ |
存放项目的数据文件,比如数据库结构、创建数据表的SQL文件,或者SQLite的数据库文件等 |
Doc/ |
存放项目文档,包括你自己的文档和PHPDoc产生的文档 |
Lib/ |
数据模型 |
Log/ |
日志文件夹,需要777权限 |
Plugins/ |
存放在应用中安装的插件 |
Test/ |
半酣单元和共性测试 |
Web/ |
WEB服务的根 |
希望本文所述对大家基于Symfony框架的PHP程序设计有所帮助。
您可能感兴趣的文章:
- Symfony2之session与cookie用法小结
- Symfony2实现从数据库获取数据的方法小结
- Symfony2实现在controller中获取url的方法
- Symfony2框架学习笔记之表单用法详解
- Symfony2框架学习笔记之HTTP Cache用法详解
- Symfony控制层深入详解
- 使用symfony命令创建项目的方法
- Symfony模板的快捷变量用法实例
- Symfony2框架创建项目与模板设置实例详解
- Symfony学习十分钟入门经典教程
- 高性能PHP框架Symfony2经典入门教程
- symfony2.4的twig中date用法分析

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Symfony is a high-performance, reusable web application framework based on the PHP language. It is used to build high-quality web applications and services and provides a variety of features and tools to simplify the development process. Symfony's goal is to make web development more usable, reusable, and efficient, and is an open source framework that follows the best software engineering practices. For PHP developers, the Symfony framework is a very good choice because it provides rich and powerful flexibility to

With the rapid development of information technology, enterprise management systems are becoming more and more popular. Among them, customer relationship management system (CRM) is a very popular enterprise management system. One of the biggest challenges facing businesses today is how to effectively manage customer relationships. Developing an efficient CRM system has become the core task of developing an enterprise. This article will introduce how to use the PHP framework Symfony, combined with its rich functions and documentation, to develop an efficient CRM system. 1. Understand the Symfony framework Symfony is a

The Symfony framework is a popular PHP framework with many advantages. This article will discuss the advantages of the Symfony framework. High degree of flexibility Symfony framework is very flexible and can meet a variety of needs. By using its different components, you can build your own blocks using your own code without having to use a mandatory architecture. This makes the Symfony framework ideal for developing highly complex applications. Strong Security Symfony framework is a very secure

Steps to implement user rights management using Symfony framework Symfony framework is a powerful PHP development framework, which can be used to quickly develop high-quality Web applications. When developing web applications, user rights management is an important part that cannot be ignored. This article will introduce the steps to implement user rights management using the Symfony framework, with code examples. Step 1: Install the Symfony framework First, we need to install the Symfony framework in the local environment. able to pass

The MVC architecture (Model-View-Controller) is one of the most popular patterns in PHP development because it provides a clear structure for organizing code and simplifying the development of WEB applications. While basic MVC principles are sufficient for most web applications, it has some limitations for applications that need to handle complex data or implement advanced functionality. Separating the model layer Separating the model layer is a common technique in advanced MVC architecture. It involves breaking down a model class into smaller subclasses, each focusing on a specific functionality. For example, for an e-commerce application, you might break down the main model class into an order model, a product model, and a customer model. This separation helps improve code maintainability and reusability. Use dependency injection

Deploy Symfony using Docker: Start development quickly Introduction: With the rapid development of cloud computing and containerization technology, Docker has become one of the preferred tools for developers to deploy and manage applications. Symfony, as a popular PHP framework, can also be deployed through Docker, which greatly simplifies the development and deployment process. This article will introduce how to use Docker to deploy Symfony applications and provide specific code examples. Step 1: Install Docke

As social media applications continue to grow, more and more developers are starting to focus on which framework is best for building such applications. Symfony and Phalcon are two very popular PHP frameworks with mature communities and powerful development tools. But if you need to develop large-scale social media applications, which framework is better? Symfony is a mature PHP framework that provides rich features and tools to help you quickly build large applications. Symfon

Symfony is a web development framework based on PHP language. It provides a series of tools and components to help developers quickly develop high-quality web applications. The Symfony framework is widely used in web applications, allowing developers to build applications that are highly scalable and flexible. In this article, we will introduce you to the Symfony framework and provide some simple guidance on how to build web applications using the Symfony framework. Install Symfon
