PHPackages                             code-atlantic/chophper - 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. code-atlantic/chophper

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

code-atlantic/chophper
======================

HTML text truncation library for PHP

1.0.1(2y ago)18491[2 issues](https://github.com/code-atlantic/chophper/issues)MITPHP

Since Oct 15Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/code-atlantic/chophper)[ Packagist](https://packagist.org/packages/code-atlantic/chophper)[ RSS](/packages/code-atlantic-chophper/feed)WikiDiscussions master Synced 1mo ago

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

Chophper - A simple text truncation utility for HTML
====================================================

[](#chophper---a-simple-text-truncation-utility-for-html)

Chophper is a PHP utility for truncating text within HTML to a given length without breaking the HTML tags.

Support for:

- Truncate chars, optionally respecting word boundaries
- Truncate words, optionally respecting sentence boundaries
- Truncate sentences, optionally respecting block boundaries
- Truncate blocks (paragraphs, lists, etc.)
- Preserving HTML tags
- Preserving HTML entities

**Note: This is an alpha version. Use at your own risk, and expect API changes towards simple and more flexible usage before the first stable release.**

Installation
------------

[](#installation)

Install via composer:

```
composer require code-atlantic/chophper
```

Usage
-----

[](#usage)

```
// Full is built to fully support HTML5 without breaking the HTML structure.
use Chophper\Full as Chophper;

$options [
    // ... see options below.
];

Chophper::truncate($html, $length, $options);
```

Options ( current, very subject to change )
-------------------------------------------

[](#options--current-very-subject-to-change-)

OptionTypeDefaultDescription`ellipsis`string`…`The string to append to the truncated text.`truncateBy`string`words`Whether to break the text by chars, words, sentences or blocks`preserveWords`boolean`false`Whether to preserve words when using chars truncation.Options (wisthlist)
-------------------

[](#options-wisthlist)

OptionTypeDefaultDescription`wordBreak`boolean`false`Whether to break the text at word boundaries.`preserveTags`boolean`false`Whether to preserve HTML tags.`tagsWhitelist`array`[]`A list of HTML tags to preserve.`tagsBlacklist`array`[]`A list of HTML tags to remove.`tagsIngoreLength`array`[]`A list of HTML tags to not count towards the length.`preserveEntities`boolean`false`Whether to preserve HTML entities.`entitiesWhitelist`array`[]`A list of HTML entities to preserve.`entitiesBlacklist`array`[]`A list of HTML entities to remove.`preserveImages`boolean`false`Whether to preserve images.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance52

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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

Every ~14 days

Total

4

Last Release

902d ago

Major Versions

0.2.1 → 1.0.02023-11-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/749586fb2ffa57fab58380cd691c0d9a8878497e47e278e21602252bd8dfe8ba?d=identicon)[danieliser](/maintainers/danieliser)

---

Top Contributors

[![danieliser](https://avatars.githubusercontent.com/u/847818?v=4)](https://github.com/danieliser "danieliser (22 commits)")[![HenkPoley](https://avatars.githubusercontent.com/u/2931213?v=4)](https://github.com/HenkPoley "HenkPoley (1 commits)")

### Embed Badge

![Health badge](/badges/code-atlantic-chophper/health.svg)

```
[![Health](https://phpackages.com/badges/code-atlantic-chophper/health.svg)](https://phpackages.com/packages/code-atlantic-chophper)
```

###  Alternatives

[lullabot/amp

A set of useful classes and utilities to convert html to AMP html (See https://www.ampproject.org/)

3802.9M10](/packages/lullabot-amp)[j0k3r/php-readability

Automatic article extraction from HTML

186808.8k6](/packages/j0k3r-php-readability)[fivefilters/readability.php

A PHP port of Readability.js

311826.8k5](/packages/fivefilters-readabilityphp)[mundschenk-at/php-typography

A PHP library for improving your web typography

78945.6k13](/packages/mundschenk-at-php-typography)[caseyamcl/toc

Simple Table-of-Contents Generator for PHP. Generates TOCs based off H1...H6 tags

92344.9k5](/packages/caseyamcl-toc)[magyarandras/amp-converter

A library to convert HTML articles, blog posts or similar content to AMP (Accelerated Mobile Pages).

65150.3k](/packages/magyarandras-amp-converter)

PHPackages © 2026

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