Zend Framework环境搭建

听说thinkphp只能做一些中小型项目,Zend Framework是官方的php框架,虽然比较复杂,但也很强大,分享一下安装过程中遇到的问题。如果你英文够好,直接推荐官网教程,本人也是根据官网教程来的。我用的环境是Windowsphp用的是wampserver(集成好的MySQLApachephp比较方便)。

首先要安装版本控制gitbcomposer,都是傻瓜式安装,没什么好讲的。安装好以后,转到wamp的网站目录下创建一个zf目录来体验一下Zend Framework框架的创建过程,比如我的目录就是D:\wampserver\wamp\www\zf。在这个空目录下单击鼠标右键打开Git Bash,用composer创建一个框架:

$ composer create-project -s dev zendframework/skeleton-application path/to/install

Do you want a minimal install (no optional packages)? Y/n
选n+Enter

Would you like to install the developer toolbar? y/N
选n+Enter

Would you like to install caching support? y/N
选n+Enter

Would you like to install database support (installs zend-db)? y/N
选y+Enter

Would you like to install forms support (installs zend-form)? y/N
选y+Enter

Would you like to install JSON de/serialization support? y/N
Would you like to install logging support? y/N
Would you like to install MVC-based console support? (We recommend migrating to zf-console, symfony/console, or Aura.CLI) y/N
Would you like to install i18n support? y/N
Would you like to install the official MVC plugins, including PRG support, identity, and flash messages? y/N
Would you like to use the PSR-7 middleware dispatcher? y/N
Would you like to install sessions support? y/N
Would you like to install MVC testing support? y/N
Would you like to install the zend-di integration for zend-servicemanager? y/N
都选n+Enter

Updating root package
    Running an update to install optional packages

...

Updating application configuration...

  Please select which config file you wish to inject 'Zend\Db' into:
  [0] Do not inject
  [1] config/modules.config.php
  Make your selection (default is 0):
选1

Remember this option for other packages of the same type? (y/N)
选y+Enter

好像后面还有一个我选的是y+Enter,无所谓,具体意思可以看官方,或者有时间再解释

然后有四种方法连接到服务器上,我介绍两种:

1、Built-in PHP web Server

$ php -S 127.0.0.1:238 -t public public/index.php
如果出错,238可以改一下,


直到出现Listening on...这时候在浏览器中访问http://127.0.0.1:238就会出现下面的成功画面,有时候可能掉线,所以要保证Listening一直在才行(wampserver要处于运行状态)


2、使用Apache

打开Apache的配置文件http.conf,或者按照我的路径找你自己的路径:D:\wampserver\wamp\bin\apache\apache2.4.18\conf


搜索到VirtualHost

找到这个文件打开,我的目录是D:\wampserver\wamp\bin\apache\apache2.4.18\conf\extra,在后面添加如下代码,DocumentRootDirectory改成自己的public目录

<VirtualHost *:80>
    ServerName zf-tutorial.localhost
    DocumentRoot D:/wampserver/wamp/www/zf/public
    SetEnv APPLICATION_ENV "development"
    <Directory "D:/wampserver/wamp/www/zf/public">
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
最后修改一下c:\windows\system32\drivers\etc\hosts文件,可能要在文件属性上添加修改权限:属性->安全->编辑在

文件末尾加上下面的代码,重启Apache,访问http://zf-tutorial.localhost即可。

127.0.0.1 zf-tutorial.localhost localhost

如果出错尝试在http.conf中查找AllowOverride,改成FileInfo或者All,先说到这儿,有问题可以交流一下。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值