1 Star 0 Fork 0

奈奈生的巴卫 / webman-sail

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简介

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)。

置顶

  1. 解决"先有鸡,还是先有蛋"问题. 无需系统有php环境,直接建立webman项目(通过docker):
curl -s "https://www.roiwk.cn/build-webman-app" | bash

这将在当前目录下建立一个'example-app'的文件夹, 默认环境为php8.1, mysql,reids的webman项目

安装 & 启动

  1. 安装依赖
composer require roiwk/webman-sail --dev
  1. webman命令执行 sail:install。这个命令用于发布 docker-compose.yml文件到你应用程序的根目录:
php webman sail:install

或者直接指定需要安装的服务:

php webman sail:install --with=mysql,redis
  1. 启动服务。
./vendor/bin/sail up

访问: http://localhost 即可。 至此,基本的环境安装已经就绪,下来是配置和使用相关的文档:

环境变量

  1. php版本默认使用8.1版本。 默认版本支持 7.4-8.2,更多可查看定制容器; 具体版本按需设置.env文件中的配置即可。
PHP_CLI_VERSION=8.1
  1. 数据库配置
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=dev
DB_PASSWORD=123456
DB_ROOT_PASSWORD=password

执行命令

  1. help,查看支持的指令帮助。
./vendor/bin/sail --help
  1. sail === docker-compose 相当于docker-compose指令。
./vendor/bin/sail up -d
./vendor/bin/sail down
./vendor/bin/sail ps
  1. sail === php-cli(container) 链接容器内部php指令。
./vendor/bin/sail php test.php
./vendor/bin/sail php -v
  1. sail === composer(container) 链接容器内部composer指令。
./vendor/bin/sail composer update
./vendor/bin/sail composer require foo/bar
./vendor/bin/sail composer remove foo/bar
  1. sail === mysql-cli 链接mysql/mariadb/psql容器内部指令。
./vendor/bin/sail mysql
  1. sail === redis-cli 链接redis容器内部指令。
./vendor/bin/sail redis
  1. sail === shell(container) 链接应用容器内部shell指令。
./vendor/bin/sail shell
./vendor/bin/sail root-shell               #root用户
  1. sail === phpunit(container) 执行应用容器内部phpunit指令。
./vendor/bin/sail phpunit --bootstrap support/bootstrap.php

...等等功能,
--help期待你的发现与探索。

定制容器

因为 Sail 就是 Docker,所以你可以自由的定制任何内容,使用 sail:publish 命令可以将 Sail 预设的 Dockerfile 发布到你的应用程序中,以便于进行定制:

./vendor/bin/sail webman sail:publish

运行这个命令后,Sail 预设好的 Dockerfile 和其他配置文件将被生成发布到项目根目录的 docker 目录中。 完成上述操作后,可以按需修改Dockerfile中的php扩展等。修改完成后,执行以下命令重新构建容器即可:

./vendor/bin/sail build --no-cache

高级用法

  1. 使用开发容器 DevContainer
./vendor/bin/sail install --devcontainer
  1. 配置别名 默认情况下,Sail 命令使用 vendor/bin/sail 脚本调用,但与其重复的输入 vendor/bin/sail 来执行 Sail 命令,你可能会希望配置一个 Bash 别名方便你更容易的执行 Sail 命令
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'

补充:通过 vim ~/.bashrc 或 vim ~/.zshrc 加入别名,可以让别名常驻。

贡献

欢迎提交PR

鸣谢

灵感与借鉴:laravel/sail

开源许可协议

MIT LICENSE

MIT License Copyright (c) 2023 roiwk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A docker compose file tool for webman. webman的docker compose文件生成工具,方便开发环境操作。 展开 收起
PHP 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/roiwk/webman-sail.git
git@gitee.com:roiwk/webman-sail.git
roiwk
webman-sail
webman-sail
main

搜索帮助