使用composer创建laravel项目:Composer could not find the config file?


按照 文档 操作,

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 laravel php

バカ友人A 10 years, 6 months ago

composer selfupdate //composer版本低?

洗手见天使 answered 10 years, 6 months ago

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

穹丶love answered 10 years, 6 months ago

在命令行里执行


 composer config -l -g

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

花甲护航绿坝娘 answered 10 years, 6 months ago

Your Answer