PHPackages                             kayw-geek/php-wordwrap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kayw-geek/php-wordwrap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kayw-geek/php-wordwrap
======================

Word-wrapping for php.

1.0.0(4y ago)222MITPHPPHP &gt;=7.1

Since Aug 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kayw-geek/php-wordwrap)[ Packagist](https://packagist.org/packages/kayw-geek/php-wordwrap)[ RSS](/packages/kayw-geek-php-wordwrap/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP-WordWrap
============

[](#php-wordwrap)

[![GitHub](https://camo.githubusercontent.com/c98611f1d97d58537bf48ba96e9e6d1e4f64e72398f07904639367734eb2c61b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6179772d6765656b2f7068702d776f726477726170)](https://camo.githubusercontent.com/c98611f1d97d58537bf48ba96e9e6d1e4f64e72398f07904639367734eb2c61b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6179772d6765656b2f7068702d776f726477726170)[![php-standard-style](https://camo.githubusercontent.com/d429b06ef11476d7ddad760f59fa8030052e35275444e21f1d4ad52fe9daf207/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d7374616e646172642d627269676874677265656e2e737667)](https://camo.githubusercontent.com/d429b06ef11476d7ddad760f59fa8030052e35275444e21f1d4ad52fe9daf207/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d7374616e646172642d627269676874677265656e2e737667)[![GitHub top language](https://camo.githubusercontent.com/048427619f54309483139e457d153ba3561a07168dc017d7162b5a5703951a58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6b6179772d6765656b2f7068702d776f726477726170)](https://camo.githubusercontent.com/048427619f54309483139e457d153ba3561a07168dc017d7162b5a5703951a58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6b6179772d6765656b2f7068702d776f726477726170)

Word wrapping, with a few features.

- force-break option
- wraps hypenated words
- multilingual - wraps any language that uses whitespace for word separation.
- custom symbol wrap mode
- chain call
- multi-format return

Install
-------

[](#install)

```
composer require kayw-geek/php-wordwrap
```

Synopsis
--------

[](#synopsis)

Wrap some text in a 20 character column.

```
> $wrap = new \KaywGeek\WordWrap();

> $text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

> $result = $wrap->text($text)->width(20)->wrap();
```

`result` now looks like this:

```
Lorem ipsum dolor
sit amet,
consectetur
adipiscing elit, sed
do eiusmod tempor
incididunt ut labore
et dolore magna
aliqua.

```

By default, long words will not break. Unless you set the `break` option.

```
> $text = "https://github.com/kayw-geek/php-wordwrap"

> $wrap->text($text)->width(28)->break(false)->wrap();
  https://github.com/kayw-geek/php-wordwrap

> $wrap->text($text)->width(28)->break()->wrap();
  https://github.com/kayw-geek
  /php-wordwrap
```

Punctuation wrap mode

```
> $text = "Of course,the first example appears to be the nicest one (or perhaps the fourth),but you may find that being able to use empty expressions in for loops comes in handy in many occasions.";

> $wrap->text($text)->lfEnable()->wrap();
```

`result`

```
Of course,
the first example appears to be the nicest one (or perhaps the fourth),
but you may find that being able to use empty expressions in for loops comes in handy in many occasions.

```

Format data

```
> $text = "Of course,the first example appears to be the nicest one (or perhaps the fourth),but you may find that being able to use empty expressions in for loops comes in handy in many occasions.";

/**
* Format List
* \KaywGeek\WordWrap::FORMAT_JSON
* \KaywGeek\WordWrap::FORMAT_STRING
* \KaywGeek\WordWrap::FORMAT_ARRAY
*/
> $wrap->text($text)
    ->lfEnable()
    ->responseFormat(\KaywGeek\WordWrap::FORMAT_JSON)
    ->wrap();
```

Inspiration
-----------

[](#inspiration)

[wordwrapjs](https://github.com/75lb/wordwrapjs)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1732d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f40052c6a2120cfd79e19ee61cc32aaf43252072be9d85caa6b25c83506eda19?d=identicon)[weikaiii](/maintainers/weikaiii)

---

Top Contributors

[![kayw-geek](https://avatars.githubusercontent.com/u/29700073?v=4)](https://github.com/kayw-geek "kayw-geek (6 commits)")

---

Tags

linetextwordwordwrapwrap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kayw-geek-php-wordwrap/health.svg)

```
[![Health](https://phpackages.com/badges/kayw-geek-php-wordwrap/health.svg)](https://phpackages.com/packages/kayw-geek-php-wordwrap)
```

###  Alternatives

[amstaffix/pagination

Simple pagination

46290.4k6](/packages/amstaffix-pagination)[faonni/module-smart-category

SmartCategory module is a base of Smart Categories functionality.

8289.3k3](/packages/faonni-module-smart-category)[sitegeist/silhouettes

Preconfigure property-silhuettes that can be applied to various properties of multiple NodeTypes.

16157.5k](/packages/sitegeist-silhouettes)[michaeljennings/refinery

A php class to refine data into a set format.

129.5k2](/packages/michaeljennings-refinery)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
