安装Zend Framework 2 Skeleton应用程序时的Composer异常

时间:2014-06-25 17:31:43

标签: php macos zend-framework zend-framework2 composer-php

我正在尝试在运行MAMP pro 3.0的MAMP服务器上设置Zendframework 2.3应用程序。我正在使用TemplateStock(http://www.templatestock.net/install-zend-framework-2-on-mac-osx-and-mamp/)上的说明。安装composer是成功的:

/Applications/MAMP$ curl -s https://getcomposer.org/installer | php -d detect_unicode=off #!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /Applications/MAMP/composer.phar
Use it: php composer.phar

然后我尝试运行以下命令来安装骨架项目:

php composer.phar create-project -sdev --repository-url="https://packages.zendframework.com" zendframework/skeleton-application /Applications/MAMP/htdocs/MyApp

我得到以下输出:

Installing zendframework/skeleton-application (dev-master 67cbbbf61897831ef1feda323be9845aa7d79682)
  - Installing zendframework/skeleton-application (dev-master master)
    Cloning master

 Created project in /Applications/MAMP/htdocs/myApp/



  [InvalidArgumentException]                                                                                                         
  Composer could not find the config file: /Users/shill/.composer/vendor/bin                                                         
  To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section  



create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [package] [directory] [version]

运行`php composer.phar diag'会为所有内容返回OK。

myApp目录中的composer.json文件如下:

{
  "name": "zendframework/skeleton-application",
  "description": "Skeleton Application for ZF2",
  "license": "BSD-3-Clause",
  "keywords": [
      "framework",
      "zf2"
  ],
  "homepage": "http://framework.zend.com/",
  "require": {
      "php": ">=5.3.3",
      "zendframework/zendframework": "2.3.*"
  }
}

已解决...需要超级用户权限

sudo php composer.phar install

1 个答案:

答案 0 :(得分:1)

你在某个时刻使用作曲家与sudo权利陷入了麻烦。现在您拥有root拥有的/Users/shill/.composer.json/目录。这导致单个项目的安装失败。

您通过使用sudo来安装项目本身也“修复”了这个问题。这不是一个修复,它只会扩大您的问题。你需要做的是再次将所有这些文件chown给自己。

假设您的用户名是shill:

chmod -R shill:shill /Users/shill/.composer.json
chmod -R shill:shill /Applications/MAMP/htdocs/myApp

确保web服务器/ php工作者能够读取myApp目录中的文件,但这应该不是很困难。