PHPackages                             cline/ancestry - 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. [Database &amp; ORM](/categories/database)
4. /
5. cline/ancestry

ActiveLibrary[Database &amp; ORM](/categories/database)

cline/ancestry
==============

Closure table hierarchies for Eloquent models with O(1) ancestor/descendant queries.

2.0.3(5mo ago)116.7k↑25.6%1MITPHPPHP ^8.5.0CI passing

Since Dec 30Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/faustbrian/ancestry)[ Packagist](https://packagist.org/packages/cline/ancestry)[ RSS](/packages/cline-ancestry/feed)WikiDiscussions 2.x Synced 2w ago

READMEChangelog (4)Dependencies (18)Versions (17)Used By (1)

[![GitHub Workflow Status](https://github.com/faustbrian/ancestry/actions/workflows/quality-assurance.yaml/badge.svg)](https://github.com/faustbrian/ancestry/actions)[![Latest Version on Packagist](https://camo.githubusercontent.com/201cb249210644b9c6c9dcc758adaf50a50fe9a57a106c296929dbd15d5ffd0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c696e652f616e6365737472792e737667)](https://packagist.org/packages/cline/ancestry)[![Software License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/9bf9f2008508c25e7a5f6cb31f4acfd802896030549aa7e0c1c577e54cf79ef3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c696e652f616e6365737472792e737667)](https://packagist.org/packages/cline/ancestry)

---

Ancestry
========

[](#ancestry)

Closure table hierarchies for Eloquent models with O(1) ancestor/descendant queries.

Ancestry implements the closure table pattern for managing hierarchical relationships in Laravel. This enables efficient queries for ancestors and descendants without recursion limits, supporting deeply nested relationships like organizational charts, sales hierarchies, and category trees.

Documentation
-------------

[](#documentation)

- [Getting Started](DOCS.md#doc-docs-readme) - Installation, requirements, and quick start
- [Basic Usage](DOCS.md#doc-docs-basic-usage) - Core operations and trait methods
- [Fluent API](DOCS.md#doc-docs-fluent-api) - Chainable, expressive interface
- [Configuration](DOCS.md#doc-docs-configuration) - Customize keys, morphs, depth limits
- [Multiple Hierarchy Types](DOCS.md#doc-docs-multiple-types) - One model, many hierarchies
- [Custom Key Mapping](DOCS.md#doc-docs-custom-key-mapping) - Advanced key configuration
- [Events](DOCS.md#doc-docs-events) - React to hierarchy changes
- [Snapshots](DOCS.md#doc-docs-snapshots) - Capture point-in-time hierarchy state

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please use the [GitHub security reporting form](https://github.com/faustbrian/ancestry/security) rather than the issue queue.

Credits
-------

[](#credits)

- [Brian Faust](https://github.com/faustbrian)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License. Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~7 days

Total

16

Last Release

152d ago

Major Versions

1.x-dev → 2.0.02026-03-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22145591?v=4)[Brian Faust](/maintainers/faustbrian)[@faustbrian](https://github.com/faustbrian)

---

Top Contributors

[![faustbrian](https://avatars.githubusercontent.com/u/22145591?v=4)](https://github.com/faustbrian "faustbrian (11 commits)")

---

Tags

laravelnestedeloquenttreehierarchyclosure tableancestorsdescendants

### Embed Badge

![Health badge](/badges/cline-ancestry/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M319](/packages/laravel-ai)[illuminate/database

The Illuminate Database package.

2.8k55.8M13.1k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M110](/packages/mongodb-laravel-mongodb)

PHPackages © 2026

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