安全高性能网站搭建(二)

一 zendframework的快速配置:

请下载:http://download.csdn.net/detail/chanya/4508143

这里再做一下介绍:

1 准备工作:

   1)打开php.ini文件 请把extension=php_pdo.dll之前的;号给去掉.或是直接在Wamp中开启Pdo模块和pdo_mysql模块

   2)打开httpd.conf文件开启rewrite_module模块并开启 .htaccess目录识别  AllowOverride  None 改成 all

2 配置application.ini文件

:

  application.ini中定义了三种 staging testing development 即 上线状态   测试状态  开发状态
[production]
;phpsettings    php中运行时环境的配置,实际上调用的是php的ini_set() 函数
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.log_errors = 1
phpSettings.log_errors_max_len = 1024
phpSettings.ignore_repeated_errors = 1
phpSettings.date.timezone = "Asia/Shanghai"
phpSettings.error_log = APPLICATION_PATH "/../lib/error/error.log"

;bootstrap    引导文件配置
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
;bootstrap.class = "Bootstrap" 此项可省略,应为默认的是Bootstrap

;autoloadernamespaces    注册自动载入的命名空间
autoloadernamespaces.0  = "DB_"
autoloadernamespaces.1  = "Help_"

;前端控制器配置
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.defaultModule = "default"

;布局配置
resources.layout.layout = "default"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/default"

;视图部分配置, 依据模块分开配置 (这部分要在Bootstrap中初始化)
resources.view.params.default.basePath = APPLICATION_PATH "/modules/default/views/"
resources.view.params.default.layout = "default"
resources.view.params.default.layoutPath = APPLICATION_PATH "/layouts/default"

resources.view.params.admin.basePath = APPLICATION_PATH "/modules/admin/views/"
resources.view.params.admin.layout = "admin"
resources.view.params.admin.layoutPath = APPLICATION_PATH "/layouts/admin"

;数据库配置(这部分要在Bootstrap中初始数据库配置)
resources.db.adapter = "mysqli"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "123456"
resources.db.params.dbname = "dxk"
resources.db.params.charset = "utf8"



#网站多语言配置
resources.translate.registry_key ="Zend_Translate"
resources.translate.adapter = array
resources.translate.options.scan ="directory"
resources.translate.locale ="zh_CN"
resources.translate.data.zh_CN = APPLICATION_PATH"/languages/zh_CN.php"
resources.translate.data.en_US = APPLICATION_PATH"/languages/en_US.php"
 
#网站生成的日志
[logger]
priority =7
file ="log/debug.txt"
;EMERG=0;ALERT=1;CRIT=2;ERR=3;WARN=4;NOTICE=5;INFO=6;DEBUG=7;
type = firebug
;stream,firebug
 
#网站生成Cache配置
[cache]
type = file
dir =APPLICATION_PATH"/cache/"
pagedir =APPLICATION_PATH"/cache/page/"
lifetime =7200
automatic_serialization =TRUE



;网站上线环境配置
[staging : production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0

;测试环境配置
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

;开发环境配置
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1


 

3 Zend_Form的用法:

 

$form->setAction('/resource/process')
     ->setMethod('post');


设置过滤器及属性:

 

$this->addElement('text', 'email', array(
            'label'      => 'Your Email:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'EmailAddress',
            )
        ));


 

 

你可能感兴趣的:(安全高性能网站搭建(二))