Home php教程 php手册 Symfony核心类概述

Symfony核心类概述

Jun 06, 2016 pm 07:32 PM
symfony core Overview

本文讲述了Symfony核心类。分享给大家供大家参考,具体如下: Symfony的核心类 Symfony的MVC方式使用了一些你以后会经常碰到的类 1. sfController是控制器,他解码请求并专递至动作(action) 2. sfRequest存储了所有的请求元素(参数、Cookies、头信息等等

本文讲述了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程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the advantages of Symfony framework? What are the advantages of Symfony framework? Jun 03, 2023 am 09:21 AM

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

Develop an efficient CRM system using the PHP framework Symfony Develop an efficient CRM system using the PHP framework Symfony Jun 27, 2023 pm 04:17 PM

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

Overview of operator overloading problems and solutions in C++ Overview of operator overloading problems and solutions in C++ Oct 08, 2023 pm 01:02 PM

Overview of Operator Overloading Problems and Solutions in C++ Introduction: Operator overloading is an important feature of the C++ language, which allows programmers to customize existing operators to operate custom data types. However, operator overloading needs to be used with caution, because if used improperly or excessively, it will lead to problems such as reduced code readability, ambiguity, and reduced efficiency. This article will outline common problems with operator overloading in C++ and provide corresponding solutions and code examples. 1. Problems with operator overloading 1.1 Ambiguity problem in operator overloading

Deploy Symfony with Docker: Get started developing quickly Deploy Symfony with Docker: Get started developing quickly Oct 20, 2023 pm 12:19 PM

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

How to use the Symfony framework in PHP How to use the Symfony framework in PHP Jun 27, 2023 am 11:16 AM

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

Apple M3 Ultra launches new version, adding 32 CPU cores and 80 GPU cores Apple M3 Ultra launches new version, adding 32 CPU cores and 80 GPU cores Nov 13, 2023 pm 11:13 PM

This chip may be equipped with up to 80 GPU cores, making it the most powerful product in the M3 series. Max has twice the number of cores. Judging from the development model of the M1 and M2 series, Apple's "Ultra" version of the chip basically has twice the number of cores of the "Max" version. This is because Apple actually uses two Max chips internally. The connection technologies are combined to form M1Ultra and M2Ultra. 80 GPU cores M3Ultra may have "up to 80 graphics processing cores." This prediction is based on the development path of Apple's chips: from the basic version to the "Pro" version, to the "Max" version with twice the number of graphics cores, and the "Ultra" version with double the number of CPU and GPU cores. For example

An advanced guide to PHP MVC architecture: unlocking advanced features An advanced guide to PHP MVC architecture: unlocking advanced features Mar 03, 2024 am 09:23 AM

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

Symfony vs Yii2: Which framework is better for developing large-scale web applications? Symfony vs Yii2: Which framework is better for developing large-scale web applications? Jun 19, 2023 am 10:57 AM

As the demand for web applications continues to grow, developers have more and more choices in choosing development frameworks. Symfony and Yii2 are two popular PHP frameworks. They both have powerful functions and performance, but when faced with the need to develop large-scale web applications, which framework is more suitable? Next we will conduct a comparative analysis of Symphony and Yii2 to help you make a better choice. Basic Overview Symphony is an open source web application framework written in PHP and is built on

See all articles