解决composer无法建立项目 2021-05-04 PHP 暂无评论 2694 次阅读 例如建立项目aaa如下 ``` composer create-project topthink/think aaa ``` ``` [InvalidArgumentException] Composer could not find a composer.json file in D:\phpStudy\PHPTutorial\WWW\aaa To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] [] ``` 提示不存在composer.json,如果我们自行建立该文件,则又提示如下 ``` Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files ``` 查看第一次提示的官方文档 https://getcomposer.org/doc/00-intro.md 在windows的cmd下,打开www目录,假设工程文件夹为syn ``` cd D:\phpStudy\PHPTutorial\WWW\syn ``` 建立composer.bat文件 ``` echo @php "%~dp0composer.phar" %*>composer.bat ``` 下载composer.phar放入syn文件夹(其实也可以在上述bat文件中直接指定到composer目录里的composer.phar) 执行`composer create-project topthink/think syn`即可创建项目 标签: composer, create 本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。