在项目目录下执行 composer init 命令
$ composer init
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [asus/test]: king/testproject
Description []: This is a test project
Author [yangyi <2497471389@qq.com>, n to skip]:
Minimum Stability []:
Package Type (e.g. library, project, metapackage, composer-plugin) []: project
License []: MIT
Define your dependencies.
Would you like to define your dependencies (require) interactively [yes]? n
Would you like to define your dev dependencies (require-dev) interactively [yes]? n
{
"name": "king/testproject",
"description": "This is a test project",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "yangyi",
"email": "2497471389@qq.com"
}
],
"require": {}
}
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": {}
}