zend create project prepare

1.php ini

安装pear

设置include_path

2.apache

AllowOverride

LoadModule rerwite去掉注释

  1. <VirtualHost *: 80>
  2.     ServerName quickstart.local
  3.     DocumentRoot /path/to/quickstart/public
  4.  
  5.     SetEnv APPLICATION_ENV "development"
  6.  
  7.     <Directory /path/to/quickstart/public>
  8.         DirectoryIndex index.php
  9.         AllowOverride All
  10.         Order allow, deny
  11.         Allow from all
  12.     </Directory>
  13. </VirtualHost>

host 127.0.0.1 quickstart.local

3.

zf create project newproject

htaccess

SetEnv APPLICATION_ENV development

       

      RewriteEngine On

      RewriteCond %{REQUEST_FILENAME} -s [OR]

      RewriteCond %{REQUEST_FILENAME} -l [OR]

      RewriteCond %{REQUEST_FILENAME} -d

      RewriteRule ^.*$ - [NC,L]

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

layout模板文件

zf enable layout

配置文件中加入resources.view[] =

配置文件中加入

resources.layout.layout = "layout"

 resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

application/layouts/scripts/layout.phtml
    1. <?php echo $this->doctype() ?>  
    2. <html>  
    3. <head>  
    4.     <?php echo $this->headTitle() ?>  
    5.     <?php echo $this->headLink() ?>  
    6.     <?php echo $this->headStyle() ?>  
    7.     <?php echo $this->headScript() ?>  
    8. </head>  
    9. <body>  
    10.     <?php echo $this->layout()->content ?>  
    11. </body>  
    12. </html> 
    13. 通过在booststrap文件中加入
      1. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap  
      2. {  
      3.     protected function _initView()  
      4.     {  
      5.         // Initialize view  
      6.         $view =   Zend_View();  
      7.         $view->doctype('XHTML1_STRICT');  
      8.         $view->headTitle('My First Zend Framework Application');  
      9.    
      10.         // Add it to the ViewRenderer  
      11.         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(  
      12.             'ViewRenderer'  
      13.         );  
      14.         $viewRenderer->setView($view);  
      15.    
      16.         // Return it, so that it can be stored by the bootstrap  
      17.         return $view;  
      18.     }  

你可能感兴趣的:(project)