PHPackages                             doganoo/php-algorithms - 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. doganoo/php-algorithms

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

doganoo/php-algorithms
======================

A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

2.1.1(3y ago)9456.0k↓28%90[6 issues](https://github.com/doganoo/PHPAlgorithms/issues)7MITPHPPHP &gt;=8.0CI failing

Since Jun 10Pushed 2y ago37 watchersCompare

[ Source](https://github.com/doganoo/PHPAlgorithms)[ Packagist](https://packagist.org/packages/doganoo/php-algorithms)[ Docs](https://www.dogan-ucar.de/phpalgorithms-2/)[ Fund](https://www.paypal.me/doganoo)[ RSS](/packages/doganoo-php-algorithms/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (7)Versions (42)Used By (7)

PHPAlgorithms
=============

[](#phpalgorithms)

[![](https://camo.githubusercontent.com/78c9d5744ea120c418e2558541fde66dd95770dfb3d1524331b4668aece36018/68747470733a2f2f7777772e646f67616e2d756361722e64652f77702d636f6e74656e742f75706c6f6164732f323031382f30392f504850416c676f726974686d732e706e67)](https://camo.githubusercontent.com/78c9d5744ea120c418e2558541fde66dd95770dfb3d1524331b4668aece36018/68747470733a2f2f7777772e646f67616e2d756361722e64652f77702d636f6e74656e742f75706c6f6164732f323031382f30392f504850416c676f726974686d732e706e67)

A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

You can find the package on Packagist:

Why Using PHPAlgorithms?
------------------------

[](#why-using-phpalgorithms)

"Algorithms + Data Structures = Programs"

Algorithms are a part of the basic toolkit for solving problems. Data Structures organize data in an efficient way. The combination of both allow the creation of smart and efficient software.

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

[](#installation)

You can install the package via composer:

```
composer require doganoo/php-algorithms
```

Usage
-----

[](#usage)

Here's an Binary Tree example:

```
use doganoo\PHPAlgorithms\Datastructure\Graph\Tree\BinaryTree;

$binaryTree = new BinaryTree();
$binaryTree->insertValue(50);
$binaryTree->insertValue(25);
$binaryTree->insertValue(75);
$binaryTree->insertValue(10);
$binaryTree->insertValue(100);

echo json_encode($binaryTree);
```

produces

```
{"nodes":{"value":50,"left":{"value":25,"left":{"value":10,"left":null,"right":null},"right":null},"right":{"value":75,"left":null,"right":{"value":100,"left":null,"right":null}}}}
```

Contributions
-------------

[](#contributions)

Feel free to send a pull request to add more algorithms and data structures. Please make sure that you read  before opening a PR. Please also consider .

Maintainer/Creator
------------------

[](#maintainercreator)

Doğan Uçar ([@doganoo](https://www.dogan-ucar.de))

License
-------

[](#license)

MIT

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96.3% 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 ~46 days

Recently: every ~156 days

Total

40

Last Release

1132d ago

Major Versions

0.0.27 → 1.0.02019-10-09

1.1.1 → 2.0.02022-05-24

PHP version history (3 changes)0.0.22PHP &gt;=7.1

1.1.0PHP &gt;=7.4

2.1.1PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![doganoo](https://avatars.githubusercontent.com/u/6998611?v=4)](https://github.com/doganoo "doganoo (155 commits)")[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (2 commits)")[![tuqqu](https://avatars.githubusercontent.com/u/47274443?v=4)](https://github.com/tuqqu "tuqqu (2 commits)")[![berezuev](https://avatars.githubusercontent.com/u/695546?v=4)](https://github.com/berezuev "berezuev (1 commits)")[![krlv](https://avatars.githubusercontent.com/u/3404064?v=4)](https://github.com/krlv "krlv (1 commits)")

---

Tags

algorithmalgorithmscracking-the-coding-interviewdatastructuresgayle-laakmann-mcdowelllistsmapsphpphp7data structuresalgorithms

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/doganoo-php-algorithms/health.svg)

```
[![Health](https://phpackages.com/badges/doganoo-php-algorithms/health.svg)](https://phpackages.com/packages/doganoo-php-algorithms)
```

###  Alternatives

[php-ds/php-ds

Specialized data structures as alternatives to the PHP array

4109.5M171](/packages/php-ds-php-ds)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

345148.0k](/packages/qaribou-immutablephp)[marcosh/lamphpda

A collection of functional programming data structures

12214.5k4](/packages/marcosh-lamphpda)[judev/php-intervaltree

Interval Tree implementation in PHP

1141.8k1](/packages/judev-php-intervaltree)[nepster-web/gambling-tech

Gambling Algorithms for Certification.

122.0k](/packages/nepster-web-gambling-tech)

PHPackages © 2026

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