run 命令支持从 .env 读取 HOST/PORT 配置
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
Research direction
Start in src/think/console/command/RunServer.php and inspect how the run command reads its host and port options, then check the project's env() configuration conventions. Done means HOST and PORT from .env provide defaults, command-line options still take precedence, and the existing 0.0.0.0 and 8000 defaults remain unchanged when neither is provided.
Written by the indexing model from the issue text.
Description
现状
php think run 的 --host 和 --port 参数只能通过命令行传入,硬编码默认值为 0.0.0.0 和 8000:
// src/think/console/command/RunServer.php
$host = $input->getOption('host');
$port = $input->getOption('port');
需求
希望在 .env 中可以配置默认值,避免每次启动都要手动传参:
[SERVER]
HOST=0.0.0.0
PORT=9000
建议改动
$host = $input->getOption('host') ?: env('server.host', '0.0.0.0');
$port = $input->getOption('port') ?: env('server.port', 8000);
改动两行,完全向后兼容,不传 env 也不传参时行为不变。命令行参数优先级最高。
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from top-think/framework
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in top-think/framework
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·