zend create project prepare

时间:2022-05-31 01:24:11

1.php ini

安装pear

设置include_path

2.apache

AllowOverride

LoadModule rerwite去掉注释

  1. <VirtualHost *:>
  2.     ServerName quickstart.local
  3.     DocumentRoot /path/to/quickstart/public
  4.     SetEnv APPLICATION_ENV "development"
  5.     <Directory /path/to/quickstart/public>
  6.         DirectoryIndex index.php
  7.         AllowOverride All
  8.         Order allow,deny
  9.         Allow from all
  10.     </Directory>
  11. </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. // Add it to the ViewRenderer
      10. $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
      11. 'ViewRenderer'
      12. );
      13. $viewRenderer->setView($view);
      14. // Return it, so that it can be stored by the bootstrap
      15. return $view;
      16. }
      17. }