amitjoc/breakify
Composer 安装命令:
composer require amitjoc/breakify
包简介
Handle new line or line break across different platform (windows, unix, mac) and envirnoment like web, cli
README 文档
README
Breakify is a lightweight PHP utility for managing and transforming line breaks across platforms and formats. Whether you're normalizing text input, preparing content for HTML output, or ensuring consistent formatting in logs or CLI tools, Breakify offers a clean, expressive API to handle it all.
Author
Amit Joshi
Backend Developer | PHP & JavaScript Specialist
GitHub: @amitjoc
LinkedIn: @amitjoc
Table of Contents
Installation
Download the Breakify library
composer require amitjoshi/breakify
Include composer
autoloadfile
include_once dirname(__DIR__) . "/vendor/autoload.php";
Create a Breakify object
$web = new Breakify();
Environment
WEB: Use when a script runs only in browser-based environments.CLI: Use when a script runs only in command-line environments.BOTH: Use when the environment is dynamic or unknown.
Feature List
- Web Example and CLI Example
beap()(bell sound for CLI)- Normalize or convert line breaks across different platforms
(Windows \r\n, Unix \n, Mac \r) - Handle other
escape charactertoo for cli (in progress)
Example for WEB
When we already know that our script only executed on WEB environment
- print
br tag
$web = new Breakify() $web->pbr(); // OUTPUT: Print's `break tag` directly $web->phr(); // OUTPUT: <hr /> $web->phrDashed(); // OUTPUT: ------- $web->phrDotted(); // OUTPUT: ....... $web->phrRidge(); // OUTPUT: _______ $web->phrDouble(); // OUTPUT: =======
Example for CLI
When we already know that our script only executed on cli environment
$cliBreak = new Breakify(); $cliBreak->getLineBreak() // returns `PHP_EOL` $cliBreak->pNewLine() // echoes single line break $cliBreak->pNewLine(true) // echoes double line break
- print carriage return also
\r - print text withing the box with desired character like —, = (in progress)
- Make a bell sound
beap()from php (available only in cli mode)
Important
functionswithpprefix directly give output likepbr(),phr(),pLineBreak()
Task List
Default
-
CLI: DefaultLineBreakis set toPHP_EOL -
WEB: DefaultLineBreakis<br />
Functions
-
isCliEnv()function will check is execution environment. returntruefor cli elsefalse -
exeEnvType()TypeWEB | CLI. it will return the output accordingly
Functions for web
- print break tag
pbr() - print horizontal tag
phr() - print
dashed lineuse functionphrDashed() - print
dotted lineuse functionphrDotted() - print
ridge lineuse functionphrRidge() - print
double lineuse functionphrDouble() - custom hr line width and height and center also with in build stylesheet
Coding Standard
- PSR 4 or PSR12
CHANGES
- namespace updated to
LineBreak\\ - made breakify class final
amitjoc/breakify 适用场景与选型建议
amitjoc/breakify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amitjoc/breakify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amitjoc/breakify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-30