php Composer 找不到 composer.json
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31900211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Composer could not find a composer.json
提问by 1N5818
I tried to install composer via brew per:
我尝试通过 brew per 安装作曲家:
In usr/local/bin
(which was not on Mavricks and I had to make personally) I did.
在usr/local/bin
(这不在小牛队上,我必须亲自制作)我做到了。
brew tap josegonzalez/homebrew-php
brew install josegonzalez/php/composer
brew tap josegonzalez/homebrew-php
brew install josegonzalez/php/composer
I can run php composer.phar
, but when I do php composer.phar install
, I get the error:
我可以运行php composer.phar
,但是当我运行时php composer.phar install
,出现错误:
Composer could not find a composer.json file in /usr/local/bin
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
Composer could not find a composer.json file in /usr/local/bin
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
So I go to the https://getcomposer.org/doc/00-intro.md
. CTRL+F".json" and nothing's there. Seriously composer?
所以我去https://getcomposer.org/doc/00-intro.md
。CTRL+ F".json" 什么也没有。认真的作曲家?
EDIT:
What I was trying to do was to have composer
executable vs php composer.phar
. This works at this point from this now.
编辑:我想做的是将composer
可执行文件与php composer.phar
. 从现在开始,这在这一点上有效。
采纳答案by 1N5818
The "Getting Started" page is the introduction to the documentation. Most documentation will start off with installation instructions, just like Composer's do.
“入门”页面是对文档的介绍。大多数文档都会从安装说明开始,就像 Composer 一样。
The page that contains information on the composer.json
file is located here- under "Basic Usage", the second page.
包含composer.json
文件信息的页面位于此处- 在“基本用法”下,第二页。
I'd recommend reading over the documentation in full, so that you gain a better understanding of how to use Composer. I'd also recommend removing what you have and following the installation instructions provided in the documentation.
我建议您完整阅读文档,以便您更好地了解如何使用 Composer。我还建议删除您拥有的内容并按照文档中提供的安装说明进行操作。
回答by 1N5818
To install composer and add to your global path:
要安装 composer 并添加到您的全局路径:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
run these in terminal. It does say if you get an error that usr doesn't exist, you do need to manually make it. I know an answer was selected, so this is for anyone who may see this in the future, as i am sometimes, and don't want to be advised to visit yet another site. Its simple just two lines, might have to be in sudo if you have permission error
在终端中运行这些。它确实说如果您收到 usr 不存在的错误,则确实需要手动制作它。我知道选择了一个答案,所以这是为将来可能会看到这个的任何人准备的,就像我有时一样,并且不想被建议访问另一个站点。它很简单,只有两行,如果您有权限错误,可能必须在 sudo 中
回答by Amini
Simple solution is install via this command :
简单的解决方案是通过以下命令安装:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
To install package it's very simple :
安装包非常简单:
composer global require "phpunit/php-invoker=1.1.*"
回答by Kai Noack
In my case, I did not copy all project files to the folder where I was running composer install
. So do:
就我而言,我没有将所有项目文件复制到我正在运行的文件夹中composer install
。所以这样做:
- Copy your project files (including the
composer.json
) to folder - open CMD (I am using ConEmu), navigate to the new folder, run
composer install
from there - It should work or throw errors in case the json file is not correct.
- 将您的项目文件(包括
composer.json
)复制到文件夹 - 打开 CMD(我正在使用ConEmu),导航到新文件夹,
composer install
从那里运行 - 如果 json 文件不正确,它应该可以工作或抛出错误。
If you just want to make composer run, create a new composer.json
file with for example:
如果您只想让 composer 运行,请创建一个新composer.json
文件,例如:
{
"require": {
"php": ">=5.3.2"
}
}
Then run composer install
.
然后运行composer install
。
回答by sean dev
I encountered the same error, and was able to solve it as follows:
我遇到了同样的错误,并能够解决它如下:
composer diagnose
to see if something is wrong with the version of composer installedcomposer self-update
to install the latest versioncomposer update
to update yourcomposer.json
file.
composer diagnose
查看安装的composer版本是否有问题composer self-update
安装最新版本composer update
更新您的composer.json
文件。
回答by Muhammad
You are in wrong directory. cd to your project directory then run composer update.
你在错误的目录中。cd 到您的项目目录,然后运行 composer update。
回答by latifa saee
In my case, I am using homestead. cd ~/Homestead
and run composer install
.
就我而言,我正在使用宅基地。cd ~/Homestead
并运行composer install
。
回答by ali shojaei
- Create a file called composer.json
- Make sure the Composer can write in the directory you are looking for.
- Update your composer.
This worked for me
- 创建一个名为 composer.json 的文件
- 确保 Composer 可以写入您要查找的目录。
- 更新您的作曲家。
这对我有用