zend framework 开发环境搭建及入门

Zend Framework (ZF) 是一种开源的, 面向对象的WEB应用程序开发框架,在PHP5下运行,使用MVC软件架构,授權模式採用BSD许可证

Zend Framework特征包括[13]

官网:

http://framework.zend.com/   

现在zend版本是2.x 下载地址:https://packages.zendframework.com/

我win7安装的是2.2.0,

Zend Framework 配置要求官方文档:http://framework.zend.com/manual/1.12/en/requirements.introduction.html

  • PHP版本大于PHP 5.2.4。
  •  Apache要开启mod_rewrite模块(如果是Windows,目前已经在IIS7上支持rewrite写法了,具体可以参考Zend Framework的Document Guide 修改VirtualHost配置(也可在创建完项目后,参考docs/Readme.txt 进行操作) 

  • LoadModule rewrite_module modules/mod_rewrite.so
    <VirtualHost *:80>
    ServerName zendframework.local 
    DocumentRoot /var/www/zendframework/public   
    SetEnv APPLICATION_ENV "development"
    <Directory  /var/www/zendframework/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    </VirtualHost>

 我的apache版本比较高,跟上面的不同。配置文件都已经模块化了。

新版本只要把这句话前面的#去掉就可以了:

LoadModule rewrite_module modules/mod_rewrite.so

这样,开启Apache对rewrite的支持。

apache开启虚拟主机功能与httpd-vhosts.conf 配置

首先,在httpd.conf下开启虚拟主机功能

找到配置项

# Virtual hosts

# Virtual hosts
#

# Virtual hosts
#Include "conf/extra/httpd-vhosts.conf"

去掉#即可。

开发时,httpd-vhosts.conf可以参考如下配置:

<VirtualHost *:80>
ServerName localhost
DocumentRoot "F:\xampp\htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName zf2.local
ServerAlias www.zf2.local
DocumentRoot "F:\xampp\htdocs\ZendSkeletonApplication\public"
</VirtualHost>

在这里,我们定义了2个虚拟主机,一个是localhost,一个是zf2.local,然后修改hosts文件:

127.0.0.1 www.zf2.local
127.0.0.1 zf2.local 

这样,我们输入zf2.local即可访问。注意,加www和不加www是不同的,上面2个都要有。

看其他教程基本都看不懂,直到这篇教程,

Zend Framework2.0(zf2) Windows上安装配置

上一篇文章中提到了Linux下安装zf2,今天说下windows的上的安装。其实步骤都是一样 的,只是安装的时候注意命令执行的路径就可以了,下面请看安装步骤:

1.到https://github.com/zendframework/ZendSkeletonApplication下载zip包解压文件到根目录

2.cd到网站根目录,执行 C:\wamp\bin\php\php5.4.3\php.exe composer.phar self-update(PHP路径替换成你自己的安装路径) ,提示Downloading: 100% ,表示下载完成。(其实就是用php.exe 执行 composer.phar)

3.执行 C:\wamp\bin\php\php5.4.3\php.exe  composer.phar install , 此时提示下载相关的包,耐心等待即可。

(安装完后并没有增加新的文件夹,而是在原来文件夹下面写入了新的文件)。

4.配置虚拟主机,这一步没有什么好说的,就是注意,把根目录配置到public ,例如我的:

<VirtualHost *:80>

ServerAdmin webmaster@qinrh-host.localhost

DocumentRoot “E:/website/zfp/public”

ServerName zfp.com

ServerAlias www.zfp.com

DirectoryIndex index.html index.php

<Directory “E:/website/zfp/public”>

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

5.浏览器打开配置的虚拟机,如果看到以下页面表示安装成功。

 上面的是官方提供的方法,可以具体参考:http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html

另外一种方法:

参考:http://avnpc.com/pages/zend-framework-2-installation-for-windows

To test that your .htaccess file is working, navigate to http://zf2-tutorial.localhost/1234 and you should see this:

/images/manual/user-guide.skeleton-application.404.png

If you see a standard Apache 404 error, then you need to fix .htaccess usage before continuing. If you’re are using IIS with the URL Rewrite Module, import the following:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [NC,L]

You now have a working skeleton application and we can start adding the specifics for our application.

 zend 2.0资料汇总:http://avnpc.com/pages/zf2-summary

http://farlee.info/archives/zend-framework-tutorial.html

http://www.docin.com/p-24008239.html

這裡就不能不提 Rob Allen 寫的文章了,這篇「 Getting Started with Zend Framework 」是學習 Zend Framework 的你一定要載回來仔細研究的好文!不過官方也提供了一篇 Quick Start ,你可以將它和 Rob Allen 的文章交互參考看看 (我個人覺得 Rob 的比較完整) 。

ZendFramework2中文手册 https://zf2-cn.readthedocs.org/en/latest/

 http://bbs.phpchina.com/thread-239139-1-1.html

原文地址:https://www.cnblogs.com/youxin/p/3097575.html