定制 aschmelyun/fleet 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

aschmelyun/fleet

Composer 安装命令:

composer require aschmelyun/fleet

包简介

Run multiple Laravel Sail websites on your local environment

README 文档

README

Latest Version on Packagist Total Downloads

Easily run multiple Laravel Sail applications at the same time locally with custom domain names.

Note: This is still new and may contain bugs, if you see something weird please create an issue

Installation

You can install the package via composer:

composer require aschmelyun/fleet --dev

Getting Started

Navigate to the root directory of your Laravel application, and stop any Sail instance if it's running. Then, use the following command to add Fleet support to your app:

php artisan fleet:add

During setup you'll be prompted to enter in a domain name. Alternatively, you can pass it in through the command line:

php artisan fleet:add my-app.localhost

After the setup finishes, you can start up Sail just like normal:

./vendor/bin/sail up

And your site will be available at the domain you provided!

Note: If you chose a domain that doesn't end in .localhost, you will need to add an entry to your hosts file to direct traffic to 127.0.0.1

Local SSL

Fleet supports local SSL on your custom domains through the power of mkcert. After you've installed it on your machine, you can use the --ssl option when using the fleet:add command to enable it for your application.

php artisan fleet:add my-app.localhost --ssl

A local certificate will be generated and stored in ~/.config/mkcert/certs. After spinning up your site with Sail, your specified domain will have https enabled.

Port Conflicts

When spinning up multiple Laravel Sail appliactions, it's likely you'll encounter an error about port conflicts between Docker containers. This is because each service has a port mapped to your local machine, and by default, they're the same across your applications.

In order to fix this, add different forwarded port numbers to each Laravel application using the .env file. For example:

  • App #1
FORWARD_DB_PORT=3306
FORWARD_REDIS_PORT=6379
  • App #2
FORWARD_DB_PORT=4306
FORWARD_REDIS_PORT=7379

This way, both applications can be spun up using Fleet and Sail, and their respective services' ports won't conflict.

Additional Usage

By default, whenever you use fleet:add, a Docker network and container are both started to handle the traffic from your local domain name(s).

You can start this manually by using:

php artisan fleet:start

If you would like to remove Fleet support from an application and return it back to the default Docker setup, you can run:

php artisan fleet:remove

To stop and remove all Fleet containers and networks that are currently running on your system, you can use the command:

php artisan fleet:stop

Why use this?

Laravel Sail uses Docker and Docker Compose to spin up containers that create a local development environment for your application.

By default, the containers are bound to the :80 port of your local machine. Spinning up a second application results in a failure due to port conflicts, but you can always adjust it so that the second app is available at something like :8081.

This can have some unintended consequences though, and can get messy juggling communication between two different applications using port numbers.

Instead, Fleet provides a small set of commands that alter your docker-compose.yml file to provide support for Traefik, a reverse proxy that runs on a Docker container.

When you add a site to Fleet, a network and a few labels are added to the Docker Compose entry for your application, and a main Traefik container is spun up to handle all local web traffic incoming to the :80 port.

This configuration allows two or more Laravel Sail applications configured to different domains to resolve to their respective running containers.

For a more in-depth look at how this all ties together, check out this video that I published on using Traefik with Docker Compose.

Changelog

Please see CHANGELOG for more information on what's recently changed.

License

The MIT License (MIT). Please see License File for more information.

aschmelyun/fleet 适用场景与选型建议

aschmelyun/fleet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78.98k 次下载、GitHub Stars 达 333, 最近一次更新时间为 2023 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 aschmelyun/fleet 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 78.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 333
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 333
  • Watchers: 5
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-15