-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# 简介 | ||
|
||
Webman Sail 是一个轻量级的命令行界面,用于与 Webman 的默认 Docker 开发环境进行交互。Sail 为使用 PHP,MySQL 和 Redis 构建 Webman 应用程序提供了一个很好的起点,而无需事先具有 Docker 经验。 | ||
|
||
Sail 的核心是 docker-compose.yml 文件和存储在项目根目录的 sail 脚本。sail 脚本为 CLI 提供了便捷的方法,可用于与 docker-compose.yml 文件定义的 Docker 容器进行交互。 | ||
|
||
Webman Sail 支持 macOS、Linux 和 Windows (通过 [WSL2](https://docs.microsoft.com/en-us/windows/wsl/about))。 | ||
|
||
|
||
## 安装 & 启动 | ||
|
||
1. 安装依赖 | ||
|
||
```shell | ||
composer require roiwk/webman-sail --dev | ||
``` | ||
|
||
2. webman命令执行 ```sail:install```。这个命令用于发布 ```docker-compose.yml```文件到你应用程序的根目录: | ||
|
||
```shell | ||
php webman sail:install | ||
``` | ||
|
||
3. 启动服务。 | ||
|
||
```shell | ||
./vendor/bin/sail up | ||
``` | ||
|
||
至此,基本的环境安装已经就绪,下来是配置和使用相关的文档: | ||
|
||
## 环境变量 | ||
1. php版本默认使用8.1版本。 默认版本支持 7.4-8.2,更多可查看[定制容器](#定制容器); 具体版本按需设置```.env```文件中的配置即可。 | ||
```env | ||
PHP_CLI_VERSION=8.1 | ||
``` | ||
|
||
2. 数据库配置 | ||
```env | ||
DB_PORT=3306 | ||
DB_DATABASE=test | ||
DB_USERNAME=dev | ||
DB_PASSWORD=123456 | ||
DB_ROOT_PASSWORD=password | ||
``` | ||
|
||
## 执行命令 | ||
|
||
1. help,查看支持的指令帮助。 | ||
```shell | ||
./vendor/bin/sail --help | ||
``` | ||
|
||
2. sail === docker-compose 相当于docker-compose指令。 | ||
```shell | ||
./vendor/bin/sail up -d | ||
./vendor/bin/sail down | ||
./vendor/bin/sail ps | ||
``` | ||
3. sail === php-cli(container) 链接有容器内部php指令。 | ||
```shell | ||
./vendor/bin/sail php test.php | ||
``` | ||
4. sail === composer(container) 链接容器内部compoer指令。 | ||
```shell | ||
./vendor/bin/sail composer update | ||
./vendor/bin/sail composer require foo/bar | ||
./vendor/bin/sail composer remove foo/bar | ||
``` | ||
5. sail === mysql-cli 链接容器内部mysql/mariadb/psql指令。 | ||
```shell | ||
./vendor/bin/sail mysql | ||
``` | ||
6. sail === redis-cli 链接容器内部redis指令。 | ||
```shell | ||
./vendor/bin/sail redis | ||
``` | ||
7. sail === shell(container) 链接应用容器内部shell指令。 | ||
```shell | ||
./vendor/bin/sail shell | ||
./vendor/bin/sail root-shell #root用户 | ||
``` | ||
8. sail === phpunit(container) 执行应用容器内部phpunit指令。 | ||
```shell | ||
./vendor/bin/sail phpunit --bootstrap support/bootstrap.php | ||
``` | ||
|
||
...等等功能, | ||
``` --help```期待你的发现与探索。 | ||
|
||
|
||
## 定制容器 | ||
|
||
因为 Sail 就是 Docker,所以你可以自由的定制任何内容,使用 ```sail:publish``` 命令可以将 Sail 预设的 Dockerfile 发布到你的应用程序中,以便于进行定制: | ||
|
||
```shell | ||
./vendor/bin/sail webman sail:publish | ||
``` | ||
|
||
运行这个命令后,Sail 预设好的 Dockerfile 和其他配置文件将被生成发布到项目根目录的 docker 目录中。 | ||
完成上述操作后,可以按需修改Dockerfile中的php扩展等。修改完成后,执行以下命令重新构建容器即可: | ||
|
||
```shell | ||
./vendor/bin/sail build --no-cache | ||
``` | ||
|
||
## 贡献 | ||
|
||
欢迎提交PR | ||
|
||
## 鸣谢 | ||
|
||
灵感与借鉴:[laravel/sail](https://github.com/laravel/sail) | ||
|
||
|
||
## 开源许可协议 | ||
|
||
[MIT LICENSE](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,16 @@ | |
"type": "library", | ||
"license": "MIT", | ||
"description": "Webman plugin roiwk/webman-sail", | ||
"keywords": [ | ||
"webman", "plugin", "sail", "webman-sail", "docker compose", "docker" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "roiwk", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "stable", | ||
"require": { | ||
"symfony/process": "^5.0|^6.0", | ||
"symfony/console": "^5.0|^6.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters