Table of Contents
韩顺平 PHP视频教程 zend framework1 zend介绍 zend快速入门" >韩顺平 PHP视频教程 zend framework1 zend介绍 zend快速入门
韩顺平 PHP视频教程 zend framework2 zend快速入门" >韩顺平 PHP视频教程 zend framework2 zend快速入门
韩顺平 PHP视频教程 zend framework3 zend原理剖析 zend整合数据库" >韩顺平 PHP视频教程 zend framework3 zend原理剖析 zend整合数据库
韩顺平 PHP视频教程 zend framework4 zend原理深度剖析" >韩顺平 PHP视频教程 zend framework4 zend原理深度剖析
Home Backend Development PHP Tutorial 韩顺平 PHP视频教程 zend framework 第1讲 ——第4讲 札记心得

韩顺平 PHP视频教程 zend framework 第1讲 ——第4讲 札记心得

Jun 13, 2016 am 10:36 AM
framework message nbsp php zend

韩顺平 PHP视频教程 zend framework 第1讲 ——第4讲 笔记心得

韩顺平 PHP视频教程 zend framework1 zend介绍 zend快速入门

Mvc 框架 –zend  framework

   zend  framework的简介

1         php流行的MVC框架介绍

a  zend  framework

b  thinkphp(国人开发)

c  yii(外企用的比较多)

d  cakephp

m  model模型

v  view 视图

c  controller控制器

 

核心的设计思想:把数据的输入,数据的处理,数据的显示分开。

框架:有zend  framework提供一个目录结构和规范,我们程序员只需要在规定的文件和位置写自己的代码就ok了。

 

优点:

程序更加规范

程序的开发效率提高了

程序的可读性增加

d 程序的可维护性增加了

不足:

配置比较复杂。

 

   为什么有zend  framework

   zend  framework的原理

    zend  framework版用户登录系统

   zend  framework的投票系统

   zend  framework购物车系统

    Php发送电子邮件。

 

快速体验案例

  目的是让大家开发zend  framework项目的基本流程,配置如何处理。

配置成功后,可以看到欢迎界面即可。

 

开发步骤:

1         下载一个最新的zend  framework

2         创建一zend  framework工程

2.1       手工创建

2.2       Zf.bat创建

2.2.1          进入zf.bat所在目录

2.2.2          使用命令zf.bat  create project 项目的全路径

 

 

2.2.3          zendstudio 创建

2.2.4          拷贝直接创建

2.2.5          引入库到项目中 library目录下库大库小不影响,因为php主要是编译

2.2.6          开始配置apache,让它支持apache框架

2.2.7          开启PDOPDO相关的数据库引擎

Php.ini中开启extension=php_pdo_mysql.dll

如果是php5.2  应该直接启动extension=php_pdo.dll

Apache的配置文件httpd.conf配置文件,修改如下

LoadModule rewrite_module modules/mod_rewrite.so

 

修改AllowOverride None

AllowOverride All

 

 

 

 

韩顺平 PHP视频教程 zend framework2 zend快速入门

 

 

配置虚拟主机:

如果开发环境是自定义安装:

启动虚拟主机,httpd.conf配置文件,修改如下

 

# Virtual hosts

Include "conf/extra/httpd-vhosts.conf"

 

Httpd-vhost.conf文件配置 配置我们自己的虚拟主机

 

#配置我们自己的虚拟主机

   DocumentRoot "F:/xampp/htdocs/zendfrm/public"

   ServerName harry.com

   DirectoryIndex  index.php  http://harry.com/index.php

   # This should be omitted in the production environment

   SetEnv APPLICATION_ENV development

 

  

       Options Indexes MultiViews FollowSymLinks

       AllowOverride All

       Order allow,deny

       Allow from all

  

 

 

 

hosts中添加dns目录

harry.com

 

 

 

 

韩顺平 PHP视频教程 zend framework3 zend原理剖析 zend整合数据库

 

 

Uml时序图

 

Httpwatch  抓取http协议包的工具。

 

 

Bootstrap.php  对所有控制器的初始化工作

 

IndexController.php 对一个控制器做的初始化工作

 

 

日志记录启动文件:

F:\xampp\htdocs\zendfrm\public\index.php12-07-26 05:31:58

F:\xampp\htdocs\zendfrm\application\Bootstrap.php12-07-26 05:31:58

F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php12-07-26 05:31:58init..

F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php12-07-26 05:31:58index..

 

用户登录后,显示消息列表。

创建数据库

 

/*

Navicat MySQL Data Transfer

 

Source Server         : localhost_3306

Source Server Version : 50516

Source Host           : localhost:3306

Source Database       : testzf

 

Target Server Type    : MYSQL

Target Server Version : 50516

File Encoding         : 65001

 

Date: 2012-07-26 14:10:03

*/

 

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------

-- Table structure for `message`

-- ----------------------------

DROP TABLE IF EXISTS `message`;

CREATE TABLE `message` (

  `message_id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `sender` varchar(64) NOT NULL,

  `getter` varchar(64) NOT NULL,

  `sendtime` datetime NOT NULL,

  `content` varchar(2000) NOT NULL,

  PRIMARY KEY (`message_id`)

) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

 

-- ----------------------------

-- Records of message

-- ----------------------------

INSERT INTO `message` VALUES ('1', '张三', '李海', '2012-07-19 14:01:33', '你好啊,还在吗?');

INSERT INTO `message` VALUES ('2', '李四', '张国荣', '2012-07-09 14:02:18', '风继续吹');

INSERT INTO `message` VALUES ('3', '回音哥', '郭德纲', '2012-07-26 14:02:39', '我的歌声里');

INSERT INTO `message` VALUES ('4', '李逍遥', 's', '2012-07-26 14:03:25', '真漂亮');

INSERT INTO `message` VALUES ('5', '张柏芝', '谢霆锋', '2012-07-27 14:04:39', '原谅我吧');

INSERT INTO `message` VALUES ('6', '周立波', '周瑾', '2012-07-30 14:05:13', '你不和我搭档了吗?');

INSERT INTO `message` VALUES ('7', '李云龙', '刘少奇', '2012-07-17 14:07:08', '我是华野的');

INSERT INTO `message` VALUES ('8', '毛总东', '邓小平', '2012-07-25 14:07:40', '全心全意为人民服务');

INSERT INTO `message` VALUES ('9', '邓小平', '江泽民', '2012-07-25 14:08:10', '发展是硬道理');

 

 

Zend一般不和smarty融合一起操作。因为它自己有。

韩顺平 PHP视频教程 zend framework4 zend原理深度剖析

总控index.php每次都经过这。即使输入harry.com/uu,只要保证前面的域名不变化,怎么访问资源都会到总控。

重写机制  .htaccess

 

RewriteEngine On   启用重写机制

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

 

.   除了\n的任意字符。

php项目中,我们通过对url的重写,可以完成整个只有一个入口的项目

 

 

.htaccess

 

多入口

RewriteRule ^.*$\.php   enter.php

RewriteRule ^.*$\.html   enter.html

 

Index发送给apache  rewrite机制记录下来 首先调用总控——boot——

 

约定俗成

如果有错误  ErrorController.php  该控制器来处理,它是处理机制。我们的控制器 区分大小写。

 

xxAction  的格式  xx不能大写 

 

总控使用了一点反射机制。

 

步骤

1 先在controllers文件下添加

class  testController extends  Zend_Controller_Action{

  public  function  init(){

   

  }

  public functionloginAction(){

    //echo '用户登录';

    $this->render("login");

  }

}

 

 

优化代码:

Bootstrap.php 数据库初始化代码的优化。

 

抽象出来一个类

//做一个父类,专门供其它的Controller来继承

class  BaseController extends Zend_Controller_Action{

 

public function init()

{

  //初始化我们的数据库适配器

 $url=constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini';

 $dbconfig=new Zend_Config_Ini($url,"mysql");

 $db=Zend_Db::factory($dbconfig->db);

 $db->query('SET NAMES  UTF8');

 Zend_Db_Table::setDefaultAdapter($db);

}

 

}

 

 

 

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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles