使用命令行创建Zend framework项目

首先创建Zend项目有多种方式:

1.下载好文件,执行解压后/bin目录下的脚本文件

2.使用sudo apt-get install zendframework 安装zend,以下是这种方法:

使用命令安装:

sudo apt-get install zend-framework,安装成功后zend目录为/usr/share/PHP/libzend-framework-php


也可以使用composer来创建

composer create-project zendframework/zendframework1 ZF1 --prefer-dist

配置:

配置include_path路径:

     修改/etc/php5/conf.d目录下的zend-framework.ini文件,仅需将include_path前的分号去掉后保存即可

开启rewrite:

在命令行下输入命令:sudo a2enmod rewrite,后重启apahce服务器

开启PHP各种模块:

pdo_mysqli等等。

用zf命令创建web project:

zf create project 项目名

运行结果如下:

	zf create project testZend
	Creating project at /var/www/testZend
	Note: This command created a web project, for more information setting up your VHOST, please see docs/README
	Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.

发现include_path找不到PHPunit,所以单元测试不能创建。(这个问题目前还不知道怎么解决)


然后是vhost虚拟主机:

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf(开启这一行)

配置apache关于本项目的信息

在/etc/apache2/conf.d中创建一个关于ZFTest的配置文件,称为 zftest.conf。文件的内容是:

<IfModule alias_module>
      Alias /zftest "/home/limin/Zend/workspaces/DefaultWorkspace7/ZFTest/public/"
      <Directory "/home/limin/Zend/workspaces/DefaultWorkspace7/ZFTest/public/">
      Allow from all
      RewriteEngine on
      RewriteBase /zftest
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule !\.(css|js|jpg|gif|png|swf|flv)$ index.php
      Options FollowSymlinks MultiViews
     AllowOverride All
     </Directory>
</IfModule>


修改ZFTest目录中public子目录里的.htaccess文件(为隐藏文件)

     在RewriteEngine On后添加一句 RewriteBase /zftest


之后只要访问目录或域名,会自动加载public下的index.php,也就是view里的index.phtml(我也不知道为什么是.phtml)






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值