建立Zendframe work 框架

 

建立Zendframe work 框架_第1张图片

关于此目录的解释:
--------------
1.在apache的主配置文家httpd.conf定义了网站的根目录  /var/www
2.配置的一个虚拟主机《文件参见:本博客apache虚拟主机一文》,网站配置文件在/var/www/phpweb20/中,包括ZF的配置文件settings.ini。
        //settings.ini [development] database.type = pdo_mysql database.hostname = localhost database.username = phpweb20 database.password = myPassword database.database = phpweb20 paths.base = /var/www/phpweb20 paths.data = /var/www/phpweb20/data paths.templates = /var/www/phpweb20/templates logging.file = /var/www/phpweb20/data/logs/debug.log //httpd.conf <VirtualHost 192.168.1.100> ServerName phpweb20 DocumentRoot /var/www/phpweb20/htdocs <Directory /var/www/phpweb20/htdocs> AllowOverride All Options All </Directory> php_value include_path .:/var/www/phpweb20/include php_value magic_quotes_gpc off php_value register_globals off ############################################ php_value date.timezone Asia/Chongqing </VirtualHost> ***************PS: <1.上面的#############下面的php_value date.timezone Asia/Chongqing是php 5.3.0的新特性 <2.apache主配置文件加入: NameVirtualHost 192.168.1.100 include /var/www/phpweb20/httpd.conf

3.在./htdocs中定于了根控制器index.php,这里使用了ZF2.0,使用了Zend_Loader_Autoloader,

 

<?php // index.php // require_once('Zend/Loader.php'); // require_once 'Zend/Loader/Autoloader.php'; // $loader = Zend_Loader_Autoloader::getInstance(); //////////////////////////////////////////ZF1.8新的引用方式///////////////////////////// require('Zend/Loader/Autoloader.php'); //Zend_Loader::registerAutoload(); Zend_Loader_Autoloader::getInstance()->registerNamespace('Zend_');//Zend框架的名字空间 Zend_Loader_Autoloader::getInstance()->registerNamespace('zlb_');//我自己的类的名字空间 Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);//能够载入无名子空间的类,比如models目 // Zend_Loader::registerAutoload(); // load the application configuration $config = new Zend_Config_Ini('../settings.ini', 'development'); Zend_Registry::set('config', $config); // create the application logger $logger = new Zend_Log(new Zend_Log_Writer_Stream($config->logging->file)); Zend_Registry::set('logger', $logger); //$logger->debug('test');///////////////////////////////////////////////////////////// //检查./data/logs/debug.log,将会出现2009-07-21T22:03:11+08:00 DEBUG (7): test,说明配置正确 // connect to the database $params = array('host' => $config->database->hostname, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->database); $db = Zend_Db::factory($config->database->type, $params); Zend_Registry::set('db', $db); //$db->query('select 1');////////////////////////////////////////////////////////////// //浏览器报错则说明数据库连接正确 // handle the user request $controller = Zend_Controller_Front::getInstance(); $controller->setControllerDirectory($config->paths->base . '/include/Controllers'); // setup the view renderer $vr = new Zend_Controller_Action_Helper_ViewRenderer(); $vr->setView(new Templater()); $vr->setViewSuffix('tpl'); Zend_Controller_Action_HelperBroker::addHelper($vr); $controller->dispatch(); ?>

  

 

 

 

4.include目录放置了各种第三方库
#ZF
/Zend
#Smarty
/Smarty
另外,可能有一些文件权限的问题,特别是编译文件夹

你可能感兴趣的:(框架,PHP,application,action,include,Zend)