laravel Composer 找不到配置文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25986258/
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-09-14 10:08:57  来源:igfitidea点击:

Composer could not find the config file

laravelcomposer-php

提问by user3833823

I want to create a laravel project by composer. I try to run this:

我想通过作曲家创建一个 Laravel 项目。我尝试运行这个:

composer create-project laravel/laravel c:/laravel --prefer-dist

There is an error which is:

有一个错误是:

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

The composer.json file is:

composer.json 文件是:

{
    "require": {
        "laravel/laravel": "4.2.0"
    }
}

I am using windows 8 and use cygwin. I also have a proxy on my computer so I set the path of HTTP_PROXY_REQUEST_FULLURI and HTTPS_PROXY_REQUEST_FULLURI to 0 and false

我正在使用 Windows 8 并使用 cygwin。我的电脑上也有一个代理,所以我将 HTTP_PROXY_REQUEST_FULLURI 和 HTTPS_PROXY_REQUEST_FULLURI 的路径设置为 0 和 false

Any idea?

任何的想法?

回答by Iram

Deletethe environment variable composer. And It will work.

删除环境变量composer。它会起作用。

回答by user3833823

I found the solution like this:

我找到了这样的解决方案:

COMPOSER=composer.json composer create-project laravel/laravel c:/laravel --prefer-dist

and it works!

它有效!

回答by x4storm

See: Composer on Windows 7 (x64): issue #1720

请参阅:Windows 7 (x64) 上的 Composer:问题 #1720

The link above recommends that you delete the environment variable COMPOSER.

上面的链接建议您删除环境变量COMPOSER

I have tried, and it worked.

我试过了,它奏效了。

回答by Siddharaj Solanki

I deleted the environment variable composer. Worked for me.

我删除了环境变量composer。对我来说有效。

回答by Leandro Vilson Battisti

You shouldnt erase the environment variable to work. If the variable name was composer, you only must change the name to composerpath. It's work to me.

你不应该擦除环境变量来工作。如果变量名称是 composer,您只需将名称更改为 composerpath。这对我来说是工作。

回答by user1170117

Just a note to everybody make sure to restart your doc command prompt windows after you remove the env by going to start type env press on Environmental, under system look for composer and remove the line. I spent an hour till i realized that i needed to restart the dam command window.

给大家一个提示,请确保在删除 env 后重新启动 doc 命令提示符窗口,方法是在环境上启动类型 env 按下,在系统下查找 composer 并删除该行。我花了一个小时才意识到我需要重新启动 dam 命令窗口。

回答by Kingston Fortune

Note: As suggested above remove Environment variables, if you remove the environment variable you may not be able to run the composer command successfully, depending on how many times composer is defined in your variables.

注意:正如上面建议的删除环境变量,如果删除环境变量,您可能无法成功运行 composer 命令,这取决于 composer 在您的变量中定义的次数。

as for me I had different composer environment variables from continuous tweaking, I had to delete them all, I decided to re-install composer using the windows installer and ticked the box that says install as developer (without including uninstall files), the I checked to see where it would install it and it showed my C:\ directory, so I accepted. After successful install I opened new git bash in my project directory, and ran the

至于我,我有不同的作曲家环境变量,因为不断调整,我不得不将它们全部删除,我决定使用 Windows 安装程序重新安装作曲家,并勾选了作为开发人员安装的框(不包括卸载文件),我检查了看看它会安装在哪里,它显示了我的 C:\ 目录,所以我接受了。成功安装后,我在我的项目目录中打开了新的 git bash,然后运行

composer install

command. and it was successful.

命令。它成功了。

回答by loki9

did you put your composer.json under c:/Laravel? if yes in your cmd:

你把你的 composer.json 放在 c:/Laravel 下了吗?如果在您的 cmd 中是:

C:\> cd Laravel

C:\Laravel> composer create-project laravel/laravel project-name --prefer-dist