PHPackages                             camoo/toc - 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. camoo/toc

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

camoo/toc
=========

Generates table of Contents from Text

1.0(6y ago)028MITPHPPHP &gt;=7.2

Since Mar 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/camoo/toc)[ Packagist](https://packagist.org/packages/camoo/toc)[ Docs](https://camoo.cm)[ RSS](/packages/camoo-toc/feed)WikiDiscussions master Synced 1mo ago

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

Generates Table Of Contents
===========================

[](#generates-table-of-contents)

 [ ![Build Status](https://camo.githubusercontent.com/9e73ca68511ed31f157dee8be6f89a23cb66090b6cdbc2e0ef95f6fea9b7354f/68747470733a2f2f7472617669732d63692e636f6d2f63616d6f6f2f746f632e7376673f6272616e63683d6d6173746572) ](https://travis-ci.com/camoo/toc)

Feature
-------

[](#feature)

This package parses a Html content with H-tags and generate Table of Contents with anchors in your content.

### Installation:

[](#installation)

```
  composer require camoo/toc
```

### Usage

[](#usage)

```
        $toc = new TableOfContents('Html Content');
		// get only table of contents part
        $onlyTableOfContents = $toc->getTableOfContents();

		// get full content with table of contents included
        $fullContent = $toc->getContent();
```

#### Basic Example:

[](#basic-example)

```
$htmlContent = Table of Contents

            This is a header tag h1

                    This is a header tag h2

                        This is a header tag h3

This is a header tag h1
Lorum ipsum doler sit amet
This is a header tag h2
Foo Bar
This is a header tag h3
```

pecifying Heading Levels to Include
-----------------------------------

[](#pecifying-heading-levels-to-include)

You can choose to include only specific *h1...h6* heading levels in your TOC. By default the script is parsing h1-h6. To do this, pass the optional parameter `$depth` to the constructor

```
$htmlContent = 'TesterBoldSub-Testlink3rd Level4rd level';

// Get TOC using h1-h3
$toc = new TableOfContents($htmlContent,3);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

2263d ago

### Community

Maintainers

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

---

Top Contributors

[![camoo](https://avatars.githubusercontent.com/u/24289021?v=4)](https://github.com/camoo "camoo (1 commits)")

---

Tags

CAMOOCamoo.HostingTable of Contents generatorTable of Contents parser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/camoo-toc/health.svg)

```
[![Health](https://phpackages.com/badges/camoo-toc/health.svg)](https://phpackages.com/packages/camoo-toc)
```

###  Alternatives

[mnito/round-robin

Round-robin schedule generation implementation in PHP

6169.4k](/packages/mnito-round-robin)

PHPackages © 2026

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