kiwicom/loopbind
Composer 安装命令:
composer require kiwicom/loopbind
包简介
🛠️️ CLI tool to easily bind localhost network interface with additional IP and ensure matching record in /etc/hosts.
README 文档
README
🛠️️ CLI tool to easily bind localhost network interface with additional IP and ensure matching record in /etc/hosts.
Warning
This tool should only be used in local environments and should not be used in production.
It is crucial to use this tool only on projects (configs) under your control as it can seriously compromise your /etc/hosts file.
This is a helper tool to be installed via composer global to machines where the localhost deployment process of
Docker composition (via docker-compose.yaml) is prepared in a way that it binds the ports on IP from localhost subnet block and multiple of such
compositions should be allowed to run in parallel (differentiated by the IP).
Practically speaking this tool ensures that the localhost network interface (lo0 on OS X) will also have another IP from localhost subnet block
(for example 127.0.0.2) and there will entry in /etc/hosts for particular domain routing to that IP (for example 127.0.0.2 example.test).
Supported platforms:
| Platform | Support |
|---|---|
| OS X | ✅ |
| Linux | ✅ |
| Windows | ❌ |
Required underlying utilities:
sudoifconfigsed
Installation
Run
composer global require kiwicom/loopbind
Then if you have composer bin directory on the PATH you can use it by calling loopbind in the CLI. So you can initialize the configuration with a CLI wizard:
$ loopbind init > ENV variable name to extract IP address from (leave empty if you want to provide manually or want random one): > > Do you want to generate random free local IP: > > [0] yes > [1] no > > no > IPv4 address from local block: > 127.0.0.1 > Hostname (leave empty to continue): > hostname > Hostname (leave empty to continue): > > New config file `.loopbind.json` was created. > Do you want to create .env file with variable IP: > > [0] yes > [1] no > > yes > File `.env` was created with variable `IP` set to `127.0.0.2`. > You appear to have .docker-compose.yml file in your directory. Run `docker compose stop`, replace port binding from `"80:80"` to `"$IP:80:80"` and then `docker copmose up`.
Usage
In the project root define a file named .loopbind.json with following content:
{
"localIPAlias": "127.11.23.1",
"hostname": "foobar.test"
}
Or when you need to bind multiple hostnames:
{
"localIPAlias": "127.11.23.1",
"hostname": ["www.foobar.test","foobar.test"]
}
Then in this directory you can run loopbind apply to run commands to ensure the binding.
Also, you can run loopbind unapply to remove it and loopbind show to show the configuration and its status.
The commands are idempotent so repeated apply/unapply does nothing (and the apply command does not even need to run the command again).
Please note, that the config is expected to be in the current working directory.
Development
This projects uses following coding standard:
- PHPCS
- PHPStan analysis (
composer stan) - PHPUnit tests. (
composer unit)
However, due to the expected side effects (changing the computer configuration after run) and application of KISS only a subset of functionality is tested automatically. Hence, testing of:
ApplyCommandUnapplyCommand
should be done manually.
kiwicom/loopbind 适用场景与选型建议
kiwicom/loopbind 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kiwicom/loopbind 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kiwicom/loopbind 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-19