下面開始教程的學習。
環(huán)境配置
apache虛擬主機的配置:
使用" www.localzend.com "作為訪問網(wǎng)址
使用“www”存放相關(guān)應(yīng)用實例
/mydev_src/zend_framework_learn/www
具體apache配置文件如下:
<VirtualHost *:80> ServerName localzend.com ServerAlias localzend.com DocumentRoot /mydev_src/zend_framework_learn/www <Directory /mydev_src/zend_framework_learn/www> Options Indexes FollowSymLinks AllowOverride all Order Allow,Deny Allow from all </Directory></VirtualHost><VirtualHost *:80> ServerName www.localzend.com ServerAlias www.localzend.com DocumentRoot /mydev_src/zend_framework_learn/www <Directory /mydev_src/zend_framework_learn/www> Options Indexes FollowSymLinks AllowOverride all Order Allow,Deny Allow from all </Directory></VirtualHost>
127.0.0.1 localzend.com
127.0.0.1 www.localzend.com
注意使用ZendFramework,apache要安裝rewrirte模塊,支持url重寫。
并且apache虛擬主機配置文件中要加入:AllowOverride all
創(chuàng)建第一個ZendFramework實例
zend studio是官方提供的開發(fā)zend_framework的最理想的工具,這里就已它為基礎(chǔ)。
這里框架庫使用的1.11.11版本。
下面采用zend studio創(chuàng)建一個簡單的實例
1.啟動zend studio
2.為了訪問方便,請設(shè)置/mydev_src/zend_framework_learn/www為你的zend studio的工作空間
3.File-new--zend framework project
4.項目名稱為zf_demo1,ProjectLayout選擇“zend_framework default project structure”,創(chuàng)建項目,完成。
5. 這時候還不能通過瀏覽器訪問,因為創(chuàng)建的項目要用到/zend_framework庫,我們需引入zend_framework庫文件
庫文件目錄是:/mydev_src/zend_framework_learn/ZendFramework-1.11.11/library
為了方便,需要修改php.ini
具體如下:
;;;;;;;;;;;;;;;;;;;;;;;;;; Paths and Directories ;;;;;;;;;;;;;;;;;;;;;;;;;;; UNIX: "/path1:/path2"include_path = ".:/mydev_src/zend_framework_learn/ZendFramework-1.11.11/library";; Windows: "path1;path2";include_path = ".;c:phpincludes";; PHP's default setting for include_path is ".;/path/to/php/pear"; http://php.net/include-path這里是linux,winddows要修改下面的,用;分割。
6.通過瀏覽器訪問http://localzend.com/zf_demo1/public/