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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:41:48  来源:igfitidea点击:

Composer could not find a composer.json

phpjsoncomposer-phposx-mavericks

提问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-phpbrew install josegonzalez/php/composer

brew tap josegonzalez/homebrew-phpbrew 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.mdCTRL+ F".json" 什么也没有。认真的作曲家?

EDIT: What I was trying to do was to have composerexecutable 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.jsonfile 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.*"

Ref : composer web site.

参考:作曲家网站

回答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。所以这样做:

  1. Copy your project files (including the composer.json) to folder
  2. open CMD (I am using ConEmu), navigate to the new folder, run composer installfrom there
  3. It should work or throw errors in case the json file is not correct.
  1. 将您的项目文件(包括composer.json)复制到文件夹
  2. 打开 CMD(我正在使用ConEmu),导航到新文件夹,composer install从那里运行
  3. 如果 json 文件不正确,它应该可以工作或抛出错误。

If you just want to make composer run, create a new composer.jsonfile 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:

我遇到了同样的错误,并能够解决它如下:

  1. composer diagnoseto see if something is wrong with the version of composer installed
  2. composer self-updateto install the latest version
  3. composer updateto update your composer.jsonfile.
  1. composer diagnose查看安装的composer版本是否有问题
  2. composer self-update安装最新版本
  3. 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 ~/Homesteadand 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 可以写入您要查找的目录。
  • 更新您的作曲家。

    这对我有用