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)18951[2 issues](https://github.com/code-atlantic/chophper/issues)MITPHP

Since Oct 15Pushed 4mo 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 today

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 75% of packages

Maintenance48

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

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

948d 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

[roundcube/roundcubemail

The Roundcube Webmail suite

7.1k2.4k3](/packages/roundcube-roundcubemail)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[silverstripe/framework

The SilverStripe framework

7313.7M2.8k](/packages/silverstripe-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M419](/packages/drupal-core-recommended)[lullabot/amp

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

3793.0M11](/packages/lullabot-amp)[code16/sharp

Laravel Content Management Framework

79164.7k8](/packages/code16-sharp)

PHPackages © 2026

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