在项目目录下执行 composer init 命令

  1. $ composer init
  2. Welcome to the Composer config generator
  3. This command will guide you through creating your composer.json config.
  4. Package name (<vendor>/<name>) [asus/test]: king/testproject
  5. Description []: This is a test project
  6. Author [yangyi <2497471389@qq.com>, n to skip]:
  7. Minimum Stability []:
  8. Package Type (e.g. library, project, metapackage, composer-plugin) []: project
  9. License []: MIT
  10. Define your dependencies.
  11. Would you like to define your dependencies (require) interactively [yes]? n
  12. Would you like to define your dev dependencies (require-dev) interactively [yes]? n
  13. {
  14. "name": "king/testproject",
  15. "description": "This is a test project",
  16. "type": "project",
  17. "license": "MIT",
  18. "authors": [
  19. {
  20. "name": "yangyi",
  21. "email": "2497471389@qq.com"
  22. }
  23. ],
  24. "require": {}
  25. }
  26. Do you confirm generation [yes]? yes

对于composer init 的结果解释

命令 解释 案例
Package name 项目名称 king/testproject
Description 项目描述(不要中文) This is a test project
Author 作者 yangyi <2497471389@qq.com
Minimum Stability 稳定版本 dev
Package Type 项目类型 project
License 开源 MIT

生成的 composer.json 文件

{
    "name": "king/testproject",
    "description": "This is a test project",
    "type": "project",
    "license": "MIT",
    "authors": [
        {
            "name": "yangyi",
            "email": "2497471389@qq.com"
        }
    ],
    "require": {}
}