承接 amitjoc/breakify 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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

PHP Version License Build Status Code Style Issues Stars

Table of Contents

Installation

Download the Breakify library

 composer require amitjoshi/breakify

Include composer autoload file

 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 character too 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

  1. functions with p prefix directly give output like pbr(),phr(),pLineBreak()

Task List

Default

  • CLI: Default LineBreak is set to PHP_EOL
  • WEB: Default LineBreak is <br />

Functions

  • isCliEnv() function will check is execution environment. return true for cli else false
  • exeEnvType() Type WEB | CLI. it will return the output accordingly

Functions for web

  • print break tag pbr()
  • print horizontal tag phr()
  • print dashed line use function phrDashed()
  • print dotted line use function phrDotted()
  • print ridge line use function phrRidge()
  • print double line use function phrDouble()
  • 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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-30