amitjoc/breakify
最新稳定版本:v0.1.0
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
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-30