reedware/sail-lite 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reedware/sail-lite

Composer 安装命令:

composer require --dev reedware/sail-lite

包简介

Docker files for basic PHP package development

README 文档

README

PHP Latest Stable Version License

Table of Contents

Introduction

Sail Lite is a light-weight command-line interface for interacting a baseline Docker environment for package development. Sail Lite was inspired by Laravel Sail, which offers a richer experience for Laravel development. Sail Lite is intended to be a lighter-weight alternative to Laravel Sail, targeting package development, and isn't specific to Laravel development.

At its heart, Sail Lite is the docker-compose.yml file and the sail script that is stored at the root of your project. The sail script provides a CLI with convenient methods for interacting with the Docker containers defined by the docker-compose.yml file.

Sail Lite is supported on macOS, Linux, and Windows (via WSL2).

Sail Lite vs Docker Compose

Under the hood, Sail Lite is just Docker. However, Sail Lite is pre-configured for PHP package development, and offers a sail binary with commands that are easier to work with.

Sail Lite Docker Compose
sail up docker compose up
sail down docker compose down
sail build docker compose build
sail bash docker compose exec -u sail dev bash

Sail Lite vs Laravel Sail

Sail Lite is intended for PHP package development, where as Laravel Sail targets the general Laravel developer experience.

If you intend to build Laravel applications, you should use Laravel Sail.

Sail Lite installs far fewer container dependencies than Laravel Sail (35 and counting), in that there's no database, cache, or node.js support.

Laravel Sail also requires several Illuminate and Symfony libraries, whereas Sail Lite has no package dependencies.

Sail Lite Laravel Sail
Sail Lite Vendor Laravel Sail Vendor

Installation and Setup

Installing into Existing PHP Environments

If you are interested in using Sail Lite with an existing PHP package, you may simply install Sail Lite using the Composer package manager. Of course, these steps assume that your existing local development environment allows you to install Composer dependencies:

composer require reedware/sail-lite --dev

After Sail Lite has been installed, you may run the install command. This command will publish the docker-compose.yml file to the root of your application.

./vendor/bin/sail install

Finally, you may start Sail Lite.

Installing into New PHP Environments

If you don't want to install PHP or Composer locally, you can install the sail binary and install your Composer dependencies from inside the new container:

mkdir -p vendor/bin
wget -O vendor/bin/sail https://raw.githubusercontent.com/tylernathanreed/sail-lite/refs/heads/master/bin/sail
chmod +x vendor/bin/sail
./vendor/bin/sail build
./vendor/bin/sail up -d
./vendor/bin/sail bash
> composer require reedware/sail-lite --dev
> exit
./vendor/bin/sail install

Configuring a Shell Alias

By default, Sail Lite commands are invoked using the vendor/bin/sail script:

./vendor/bin/sail up -d

However, instead of repeatedly typing vendor/bin/sail to execute Sail Lite commands, you may wish to configure a shell alias that allows you to execute Sail's commands more easily:

alias sail='$([ -f sail ] && echo sail || echo vendor/bin/sail)'

To make sure this is always available, you may add this to your shell configuration file in your home directory, such as ~/.zshrc or ~/.bashrc, and then restart your shell.

Once the shell alias has been configured, you may execute Sail Lite commands by simply typing sail. The remainder of this documentation's examples will assume that you have configured this alias:

sail up -d

Rebuilding Images

Sometimes you may want to completely rebuild your Sail Lite images to ensure all of the image's packages and software are up to date. You may accomplish this using the build command:

sail down

sail build --no-cache

sail up

Starting and Stopping

Sail Lite's docker-compose.yml file defines a single development container to help you build PHP packages.

To start the development container, you should execute the up command:

sail up

To start the development container in the background, you may start Sail Lite in "detached" mode:

sail up -d

To stop the development container, you may simply press Control + C to stop the container's execution. Or, if the container is running in the background, you may use the stop command:

sail stop

Executing Commands

When using Site Lite, you package is executing within a Docker container, and is isolated from your local computer. You may use the shell command to connect to your development container, allowing you to execute arbitrary shell commands within the container.

sail shell

sail root-shell

PHP Versions

By default, Sail Lite uses the latest version of PHP. However, this can be changed in your docker-compose.yml file:

services:
    dev:
        image: sail-lite/basic
        build:
            context: ./vendor/reedware/sail-lite/runtimes/basic
            dockerfile: Dockerfile
            args:
                PHP: '${PHP_VERSION:-8.5}' # <-- PHP Version
                WWWGROUP: '${WWWGROUP}'
        environment:
            WWWUSER: '${WWWUSER}'
        volumes:
            - '.:/var/www/html'

You can either override the PHP arg directly, its default value, or specify a PHP_VERSION setting in your .env file.

After updating your package's docker-compose.yml file, you should rebuild your container image

sail down

sail build --no-cache

sail up -d

Customization

Since Sail Lite is just Docker, you are free to customize nearly everything about it. To publish Sail Lite's own Dockerfiles, you may execute the publish command:

sail publish

After running this command, the Dockerfiles and other configuration files used by Sail Lite will be placed within a docker directory in your package's root directory. After customizing your Sail Lite installation, you may wish to change the image name for the development container in your package's docker-compose.yml file. After doing so, rebuild your development container using the build command. Assigning a unique name to the application image is particularly important if you are using Sail Lite to develop multiple PHP packages on a single machine:

sail build --no-cache

reedware/sail-lite 适用场景与选型建议

reedware/sail-lite 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 7.41k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「dev」 「docker」 「sail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 reedware/sail-lite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 reedware/sail-lite 我们能提供哪些服务?
定制开发 / 二次开发

基于 reedware/sail-lite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 16
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-07