• 解决ZF2_PATH environment


    本方法基于:ZendFramework 2.1.4版本在WIN7下构建,其他版本的安装方式相差不大。
    操作之前您需要搭建好PHP运行环境,保证PHP版本不低于PHP 5.3.3,并且去http://framework.zend.com/downloads/latest下载好ZF2的library。

    方式一,最简单方便的安装方式

    直接去https://github.com/zendframework/ZendSkeletonApplication下载项目文件,然后把下载的ZF2中的library所有文件直接拷贝到vendor/ZF2目录中(目录格式为vendorF2libraryend)。

    方式2. 官方推荐安装方式

    1. 下载ZendFramework-2.1.4,提取其中的zend目录。

    2. 在php.ini中添加 include_path = “.;c:你的目录end”。

    (此处 建立虚拟目录啊、改HOSTS文件什么的都不详解了)

    3. 此时可以去https://github.com/zendframework/ZendSkeletonApplication下载使用了,但是直接访问的时候的时间提示

    Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.' in...
    

    4. 我们直接采用设置ZF2_PATH环境的方法。找到http.conf 文件 添加SetEnv ZF2_PATH “C:/<你的ZF2框架目录>”(注意这里不需要添加路径zend)。

    方式3: 在线安装

    1. 直接去https://github.com/zendframework/ZendSkeletonApplication下载运行。

    2. 这时候我们选择php composer.phar install 的方式来安装,用CMD进入到composer.phar所在目录执行 php composer.phar install ,这时候可能会出现两种错误

    一种是:

    'php' 不是内部或外部命令,也不是可运行的程序或批处理文件。 

    很显然是没有找到PHP环境,这时候自己去配置好环境就行(怎么配置PHP环境变量?打开“我的电脑”->“属性”->“高 级”->“环境变量”->“系统变量”->“path”,编辑其值,添加你的PHP所有路径就行了),要是觉得麻烦我试了下把整个 PHP的运行文件复制到目录下也能行(当然不推荐这样,太乱了)。

    另一种是:

    This dev build of composer is outdated, please run "composer.phar self-update" t
    o get the latest version.
    Loading composer repositories with package information
    Installing dependencies
    - Installing zendframework/zendframework (2.1.4)
    
    [RuntimeException]
    You must enable the openssl extension to download files via https
    
    install [--prefer-source] [--dry-run] [--dev] [--no-custom-installers] [--no-scr
    ipts] [-v|--verbose]
    

    此时只需要开启php.ini中的extension=php_openssl.dll就行了

    3 .要是出现

    This dev build of composer is outdated, please run "composer.phar self-update" t
    o get the latest version.
    Loading composer repositories with package information
    Installing dependencies
    - Installing zendframework/zendframework (2.1.4)
    Downloading: 100%
    
    zendframework/zendframework suggests installing doctrine/common (DoctrineCommon
    >=2.1 for annotation features)
    zendframework/zendframework suggests installing ext-intl (ext/intl for i18n feat
    ures)
    zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback r
    andom byte generator for ZendMathRand if OpenSSL/Mcrypt extensions are unavail
    able)
    zendframework/zendframework suggests installing pecl-weakref (Implementation of
    weak references for ZendStdlibCallbackHandler)
    zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf f
    or creating PDF representations of barcodes)
    zendframework/zendframework suggests installing zendframework/zendservice-recapt
    cha (ZendServiceReCaptcha for rendering ReCaptchas in ZendCaptcha and/or Zend
    Form)
    Writing lock file
    Generating autoload files
    

    就说明已经安装成功了,此中方法不需要添加php include_path ,也不需要向添加ZF2_PATH环境。

    至此PHP的安装算是基本上完成了

    下面讲进行一些相关的配置:

    1. 配置apache

    1.1开启URL重写功能
    1.2 配置虚拟目录

    <VirtualHost *:80>
        ServerName zf2.localhost
        DocumentRoot zf2项目路径/public
        SetEnv APPLICATION_ENV "development"
            <Directory zf2项目路径/public>
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

    1.3 将域名zf2.localhost指向本机,在hosts文件(路径:c:windowssystem32driversetchosts)中添加

    127.0.0.1 zf2.localhost

    此时通过域名zf2.localhost就可以直接访问到你的项目了。

  • 相关阅读:
    算法总结之 自然数组的排序
    算法总结之 计算数组最小和
    算法总结之 未排序数组中累加和小于或等于给定值的最长子数组长度
    算法总结之 未排序数组中累加和为给定值的最长子数组系列问题
    wget镜像网站并且下载到指定目录 2012-06-20 19:40:56
    用wget做站点镜像
    【亲测好用!】shell批量采集百度下拉框关键词
    网站发的文章有收录 但是没有排名怎么处理
    NGINX + LUA实现复杂的控制
    Linux下php安装Redis扩展
  • 原文地址:https://www.cnblogs.com/danmao/p/4276053.html
Copyright © 2020-2023  润新知