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(2mo ago)05.6k↑36.6%1MITPHPPHP ^8.5.0CI passing

Since Dec 30Pushed 2mo agoCompare

[ Source](https://github.com/faustbrian/ancestry)[ Packagist](https://packagist.org/packages/cline/ancestry)[ RSS](/packages/cline-ancestry/feed)WikiDiscussions 2.x Synced 1mo 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

49

—

FairBetter than 95% of packages

Maintenance88

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

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

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

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[silber/bouncer

Eloquent roles and abilities.

3.6k4.4M25](/packages/silber-bouncer)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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