PHPackages                             carlcs/craft-textstatistics - 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. carlcs/craft-textstatistics

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

carlcs/craft-textstatistics
===========================

Text Statistics plugin for Craft CMS

v1.0.1(10y ago)1130PHPPHP &gt;=5.4.0

Since May 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/carlcs/craft-textstatistics)[ Packagist](https://packagist.org/packages/carlcs/craft-textstatistics)[ RSS](/packages/carlcs-craft-textstatistics/feed)WikiDiscussions master Synced 4w ago

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

Text Statistics plugin for Craft CMS
====================================

[](#text-statistics-plugin-for-craft-cms)

This Craft plugin provides Twig functions to display information about your texts. It allows you to measure the readability of your content, calculate the average reading time or access other text statistics like sentence count.

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

[](#installation)

The plugin is available on Packagist and can be installed using Composer. You can also download the [latest release](https://github.com/carlcs/craft-textstatistics/releases/latest) and copy the files into craft/plugins/textstatistics/.

```
$ composer require carlcs/craft-textstatistics

```

Settings
--------

[](#settings)

The plugin can be configured with a craft/config/textstatistics.php config file to set the default template used to render the reading time string and to set a default words per minute value.

TextStatisticsModel
-------------------

[](#textstatisticsmodel)

When you generate text statistics using the getTextStatistics function the plugin returns a TextStatisticsModel with the following properties populated. Most of the data is calculated with the excellent [Text Statistics](https://github.com/DaveChild/Text-Statistics) library by Dave Child. For information about the provided readability scores have a look these Wikipedia articles:

- [Gunning Fog Index](https://en.wikipedia.org/wiki/Gunning_fog_index)
- [Flesch Kincaid Reading Ease](https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests)

#### Properties

[](#properties)

- `textLength`
- `letterCount`
- `syllableCount`
- `wordCount`
- `sentenceCount`
- `readingTime`
- `readingTimeMinutes`
- `readingTimeString`
- `gunningFog`
- `fleschKincaid`

Templating Examples
-------------------

[](#templating-examples)

#### A single article

[](#a-single-article)

```
{% do addToTextStatistics(entry.text) %}

{% set statistics = getTextStatistics() %}
{{ statistics.readingTimeString }}

{# outputs "21 minutes" #}
```

#### Adjust WPM according to text language

[](#adjust-wpm-according-to-text-language)

```
{% set wpm = {
    'en': 200,
    'fr': 180,
} %}

{% set statistics = getTextStatistics(null, wpm[craft.locale]) %}
{{ statistics.readingTimeString }}

{# outputs "moins de 5 minutes" #}
```

#### Usage with a Matrix field

[](#usage-with-a-matrix-field)

```
{% for block in entry.article %}

    {% if block.type == 'text' %}
        {% do addToTextStatistics(block.text) %}
        {{ block.text }}
    {% endif %}

    {% if block.type == 'image' %}
        {% set image = block.image.first() %}
        {% if image %}
            {% do addToReadingTime(10) %}

        {% endif %}
    {% endif %}

{% endfor %}

{% set statistics = getTextStatistics() %}
```

Twig functions
--------------

[](#twig-functions)

#### addToTextStatistics( text, articleId )

[](#addtotextstatistics-text-articleid-)

Adds text to the data storage so you can later perform text statistics calculations from it.

- **`text`** (required) – The text to add to the data storage for text statistics. It can contain HTML tags, the plugin removes them before doing its calculations.
- **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page.

```
{% do addToTextStatistics(entry.myRichTextField) %}
```

Alternativly you can use the Twig filter.

```
{{ entry.myRichTextField|addToTextStatistics }}
```

#### addToReadingTime( seconds, articleId )

[](#addtoreadingtime-seconds-articleid-)

Adds time to the data storage to further influence the reading time returned with the text statistics.

- **`seconds`** (required) – Time in seconds to add to the data storage for text statistics.
- **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page.

```
{% do addToReadingTime(15) %}
```

#### getTextStatistics( articleId, wpm, readingTimeTemplate )

[](#gettextstatistics-articleid-wpm-readingtimetemplate-)

Performs the text statistics calculations for an article and returns the result as a TextStatisticsModel.

- **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page.
- **`wpm`** (default `200`) – The average reading speed used for the reading time calculations in words per minute units.
- **`readingTimeTemplate`** (default ) – The Twig template code used to render for the reading time string.

```
{% set statistics = getTextStatistics() %}
{{ statistics.gunningFog }}

{# outputs "12.1" #}
```

Requirements
------------

[](#requirements)

- PHP 5.4+

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~1 days

Total

2

Last Release

3686d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7516543?v=4)[carlcs](/maintainers/carlcs)[@carlcs](https://github.com/carlcs)

---

Top Contributors

[![carlcs](https://avatars.githubusercontent.com/u/7516543?v=4)](https://github.com/carlcs "carlcs (3 commits)")

### Embed Badge

![Health badge](/badges/carlcs-craft-textstatistics/health.svg)

```
[![Health](https://phpackages.com/badges/carlcs-craft-textstatistics/health.svg)](https://phpackages.com/packages/carlcs-craft-textstatistics)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

9.8k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

78149.7k3](/packages/mediawiki-maps)[rainlab/blog-plugin

Blog plugin for October CMS

17158.6k](/packages/rainlab-blog-plugin)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19246.3k2](/packages/civicrm-civicrm-drupal-8)[starcitizentools/citizen-skin

A beautiful, usable, responsive MediaWiki skin with in-depth extension support. Originally developed for the Star Citizen Wiki.

3355.8k](/packages/starcitizentools-citizen-skin)

PHPackages © 2026

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