当前位置:Gxlcms > PHP教程 > 使用composer创建laravel项目:Composercouldnotfindtheconfigfile?

使用composer创建laravel项目:Composercouldnotfindtheconfigfile?

时间:2021-07-01 10:21:17 帮助过:32人阅读

按照文档操作,

1.先安装composer,然后下载laravel安装包:
composer global require "laravel/installer=~1.1"
命令执行成功。

2.将目录~/.composer/vendor/bin添加到系统环境变量中。
3.运行laravel new test命令创建laravel项目,报错如下:

E:\>laravel new test
Crafting application...
Composer could not find the config file: C:\Users\yanwushu\vendor\bin
To initialize a project, please create a composer.json file as described in the
https://getcomposer.org/ "Getting Started" section
Application ready! Build something amazing.

个人对composer和laravel都没有比较清晰的理解,请熟悉的同志给予指点。

回复内容:

按照文档操作,

1.先安装composer,然后下载laravel安装包:
composer global require "laravel/installer=~1.1"
命令执行成功。

2.将目录~/.composer/vendor/bin添加到系统环境变量中。
3.运行laravel new test命令创建laravel项目,报错如下:

E:\>laravel new test
Crafting application...
Composer could not find the config file: C:\Users\yanwushu\vendor\bin
To initialize a project, please create a composer.json file as described in the
https://getcomposer.org/ "Getting Started" section
Application ready! Build something amazing.

个人对composer和laravel都没有比较清晰的理解,请熟悉的同志给予指点。

在命令行里执行

composer config -l -g

在输出的结果中,其中的 【home】 配置项内容就是了composer的主目录,然后进入vendor\bin,将这个路径加入环境变量。
从上面的报错信息里可以看出,你用来初始化项目的vendor\binC:\Users\yanwushu\vendor\bin,你需要确定这个路径是composer的主目录,且下面的vendor\bin存在。建议执行一下我上面说的方法,查看一下路径,然后添加正确路径到环境变量。

建议在检查下第2步的操作

composer selfupdate//composer版本低?

人气教程排行