zend create project prepare
1.php ini
安装pear
设置include_path
2.apache
AllowOverride
LoadModule rerwite去掉注释
-
<VirtualHost *:80>
-
ServerName quickstart.local
-
DocumentRoot /path/to/quickstart/public
-
-
SetEnv APPLICATION_ENV "development"
-
-
<Directory /path/to/quickstart/public>
-
DirectoryIndex index.php
-
AllowOverride All
-
Order allow,deny
-
Allow from all
-
</Directory>
-
</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
- <?php echo $this->doctype() ?>
- <html>
- <head>
- <?php echo $this->headTitle() ?>
- <?php echo $this->headLink() ?>
- <?php echo $this->headStyle() ?>
- <?php echo $this->headScript() ?>
- </head>
- <body>
- <?php echo $this->layout()->content ?>
- </body>
- </html>
- 通过在booststrap文件中加入
- class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
- {
- protected function _initView()
- {
- // Initialize view
- $view = Zend_View();
- $view->doctype('XHTML1_STRICT');
- $view->headTitle('My First Zend Framework Application');
- // Add it to the ViewRenderer
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
- 'ViewRenderer'
- );
- $viewRenderer->setView($view);
- // Return it, so that it can be stored by the bootstrap
- return $view;
- }
- }