PHPackages                             julien-boudry/condorcet - 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. julien-boudry/condorcet

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

julien-boudry/condorcet
=======================

Complete election manager, providing natively many voting methods including: Condorcet / Borda (+ Nauru variant) / Copeland / Dodgson (2 Approximations) / FTPT / Instant-runoff (alternative vote) / Kemeny–Young / Minimax (+ variants) / Ranked Pairs (+ variants) / Schulze (+ variants), Single Transferable Vote (STV) / Comparison of Pairs of Outcomes by the Single Transferable Vote (CPO-STV)

v5.0.7(2mo ago)1279.6k↓50%13[8 issues](https://github.com/julien-boudry/Condorcet/issues)1MITPHPPHP ^8.4CI passing

Since Apr 12Pushed 1mo ago11 watchersCompare

[ Source](https://github.com/julien-boudry/Condorcet)[ Packagist](https://packagist.org/packages/julien-boudry/condorcet)[ Docs](https://github.com/julien-boudry/Condorcet)[ Fund](https://blockchair.com/bitcoin/address/bc1q3jllk3qd9fjvvuqy07tawkv7t6h7qjf55fc2gh)[ GitHub Sponsors](https://github.com/sponsors/julien-boudry)[ RSS](/packages/julien-boudry-condorcet/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (229)Used By (1)

 [![Condorcet](https://raw.githubusercontent.com/julien-boudry/Condorcet/master/Assets/Logos/condorcet-logo.png)](https://raw.githubusercontent.com/julien-boudry/Condorcet/master/Assets/Logos/condorcet-logo.png)

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=master&repo=17303525&devcontainer_path=.devcontainer%2Fdevcontainer.json)

[![License](https://camo.githubusercontent.com/480b38e96a5279aad09d4fd81fa19c7f3f1b0e3c2b5daeb312d4c9d7d77e9f40/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f6769746875622f6c6963656e73652f6a756c69656e2d626f756472792f636f6e646f726365743f7374796c653d666f722d7468652d6261646765)](LICENSE.txt)[![Packagist](https://camo.githubusercontent.com/5b74aa9092dcc26ecc7da86c1b04ed07d47df11e6fe905763558e805e4bf88c0/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f7061636b61676973742f762f6a756c69656e2d626f756472792f636f6e646f726365742e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/julien-boudry/condorcet)[![Docker Pulls](https://camo.githubusercontent.com/73fc97d7605f9a99d9ce3fa409c1e19cda8c23c9025da665c8d81a7890f353d9/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f646f636b65722f70756c6c732f6a756c69656e626f756472792f636f6e646f726365743f7374796c653d666f722d7468652d6261646765)](https://hub.docker.com/r/julienboudry/condorcet)[![Packagist Download](https://camo.githubusercontent.com/12056edf94c737ca08e7117180e7c02f2e788d5a9b986c9204641581414a06ab/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f7061636b61676973742f64742f6a756c69656e2d626f756472792f636f6e646f726365742e7376673f7374796c653d666f722d7468652d6261646765266c6162656c3d5061636b6167697374253230446f776e6c6f6164)](https://packagist.org/packages/julien-boudry/condorcet)[![GitHub contributors](https://camo.githubusercontent.com/cd74c73f824e8e929e10bb64999b79dd48d1b00ed2dd635c1260f4fbc347d1e4/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f6769746875622f636f6e7472696275746f72732f6a756c69656e2d626f756472792f436f6e646f726365742e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/julien-boudry/Condorcet/graphs/contributors)

[![Codacy Badge](https://camo.githubusercontent.com/5c17d5b0b5be8ddea5ccf4f5155fb877a93950543eb3a2d4fb894f1a3afdba48/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f636f646163792f67726164652f66333465333534373033353134616236383234386130633939356134393133613f7374796c653d666f722d7468652d6261646765266c6162656c3d436f64616379253230436f64652532305175616c697479)](https://app.codacy.com/gh/julien-boudry/Condorcet/dashboard?utm_source=github.com&utm_medium=referral&utm_content=julien-boudry/Condorcet&utm_campaign=Badge_Grade)[![GitHub code size in bytes](https://camo.githubusercontent.com/50ab17a45fae36f55c55f988b2ae32fc40f98d187cbefe8c1ccc5e10772ff515/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f6769746875622f6c616e6775616765732f636f64652d73697a652f6a756c69656e2d626f756472792f436f6e646f726365742e7376673f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/50ab17a45fae36f55c55f988b2ae32fc40f98d187cbefe8c1ccc5e10772ff515/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f6769746875622f6c616e6775616765732f636f64652d73697a652f6a756c69656e2d626f756472792f436f6e646f726365742e7376673f7374796c653d666f722d7468652d6261646765)[![Codacy Badge](https://camo.githubusercontent.com/86e71daadeea9be09beecbe58cb41f6bd8cba4ac32e7b8e01c00cec1f9050c89/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f636f646163792f636f7665726167652f66333465333534373033353134616236383234386130633939356134393133613f7374796c653d666f722d7468652d6261646765)](https://app.codacy.com/gh/julien-boudry/Condorcet/dashboard?utm_source=github.com&utm_medium=referral&amp)[![Build Status](https://camo.githubusercontent.com/38230b97fb918bdf33862026ff70d5ff001ec94dfeddf9576ec9603282d373e4/68747470733a2f2f6433673333637a3569356f6d6b392e636c6f756466726f6e742e6e65742f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a756c69656e2d626f756472792f436f6e646f726365742f657865637574655f616c6c5f74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666f722d7468652d6261646765266c6162656c3d5465737473)](https://github.com/julien-boudry/Condorcet/actions)

> Main Author: [Julien Boudry](https://www.linkedin.com/in/julienboudry/)
> License: [MIT](LICENSE.txt) - *Please [say hello](https://github.com/julien-boudry/Condorcet/discussions/categories/your-condorcet-projects) if you like or use this code!*
> Contribute: [Contribution File](CONTRIBUTING.md)
> Donation: **₿ [bc1q3jllk3qd9fjvvuqy07tawkv7t6h7qjf55fc2gh](https://blockchair.com/bitcoin/address/bc1q3jllk3qd9fjvvuqy07tawkv7t6h7qjf55fc2gh)** or **[GitHub Sponsor Page](https://github.com/sponsors/julien-boudry)**
> *You can also offer me a bottle of good wine.*

> 🗳️ **Also discover [Condorcet Desktop](https://github.com/julien-boudry/Condorcet.Desktop)** — a graphical app to run elections without any code, also available online at [desktop.condorcet.vote](https://desktop.condorcet.vote)

Condorcet PHP
=============

[](#condorcet-php)

> **Presentation | [Documentation Book](https://docs.condorcet.io) | [API Reference](/Docs/api-reference/README.md) | [Voting Methods](/Docs/VotingMethods.md) | [Tests](https://github.com/julien-boudry/Condorcet/tree/master/tests)**

Condorcet is a powerful engine for managing electoral processes and calculating election results. It handles all aspects from configuration and vote collection to result calculation. The library natively implements over 20 voting methods compatible with preferential voting ballots, including Condorcet methods, Alternative Voting, STV, and many others. =&gt; [**See all supported voting methods**](#supported-voting-methods)

**Two ways to use Condorcet:**

- **[Command Line Application](#use-condorcet-as-a-command-line-application)**: For quick access to essential features without technical expertise. Easily compute election results and statistics.
- **[PHP Library](#use-condorcet-as-a-php-library)**: Integrate into your code to access all advanced features (custom manipulations, extensions, performance optimizations, advanced I/O methods, etc.).

Both approaches can handle massive numbers of votes (hundreds of millions) on modest hardware.

Summary
-------

[](#summary)

- [Condorcet PHP](#condorcet-php)
    - [Project State and Specifications](#project-state-and-specifications)
    - [Supported Voting Methods](#supported-voting-methods)
        - [Single-Winner Methods provided natively](#single-winner-methods-provided-natively)
            - [Deterministic](#deterministic)
            - [Lotteries](#lotteries)
        - [Proportional Methods provided natively](#proportional-methods-provided-natively)
        - [Add your own voting method as a module](#add-your-own-voting-method-as-a-module)
    - [Main Features](#main-features)
    - [Use Condorcet as a command line application](#use-condorcet-as-a-command-line-application)
        - [Install as a command line application](#install-as-a-command-line-application)
        - [Condorcet Book - Command Line](#condorcet-book---command-line)
    - [Use Condorcet as a PHP Library](#use-condorcet-as-a-php-library)
        - [Install / Autoloading](#install--autoloading)
        - [Library Manual](#library-manual)
        - [Class &amp; API References](#class--api-references)
        - [PHP Library - Examples](#php-library---examples)
    - [Performance &amp; Coding Style Considerations](#performance--coding-style-considerations)
        - [Coding Standards](#coding-standards)
        - [Performance](#performance)
    - [Roadmap for Further Releases](#roadmap-for-further-releases)
    - [Related projects / They use Condorcet](#related-projects--they-use-condorcet)

Project State and Specifications
--------------------------------

[](#project-state-and-specifications)

> [**Release Notes**](CHANGELOG.md)

VersionPHP RequirementsStateSupport5.08.4Stable✔ *support provided*4.78.3Old Stable✔ *support provided*4.68.2Old Stable❌ *not any support*3.x8.1Old Stable❌ *not any support*2.27.4Old Stable❌ *support requiring some incentive*2.07.1Old Stable❌ *not any support*1.05.6Old Stable❌ *not any support*0.9x5.5Old Stable❌ ℹ *Since v0.90, you should consider then it's a new project (api, engine).*0.145.5Old Stable❌ *ready for the museum**All versions require Json and Mbstring extensions (or polyfill). Pdo-Sqlite is recommended for elections with hundreds of thousands of votes or more.*

Supported Voting Methods
------------------------

[](#supported-voting-methods)

Condorcet supports both "single-winner" methods *(with full ranking extrapolation)* and proportional representation systems.

[**Full details on voting methods, options, and implementation choices**](Docs/VotingMethods.md)

### Single-Winner Methods provided natively

[](#single-winner-methods-provided-natively)

Single-winner methods return a complete ranking of all candidates.

#### Deterministic

[](#deterministic)

> Condorcet / Borda (+ Nauru variant) / Copeland / Dodgson (2 Approximations) / FPTP / Instant-runoff (alternative vote) / Kemeny–Young / Minimax (+ variants) / Ranked Pairs (+ variants) / Schulze (+ variants)

#### Lotteries

[](#lotteries)

> Random Ballot / Random Candidates

### Proportional Methods provided natively

[](#proportional-methods-provided-natively)

Methods designed for electing multiple candidates to an assembly.

> Single Transferable Vote *(STV)* / Comparison of Pairs of Outcomes by the Single Transferable Vote *(CPO-STV)* / Highest Averages Methods *(Sainte-Laguë, Jefferson/D'Hondt, and variants)* / Largest Remainder Methods *(with different quotas)*

### Add your own voting method as a module

[](#add-your-own-voting-method-as-a-module)

Condorcet features a modular architecture allowing easy extension with new algorithms:

- [Documentation on creating voting methods](https://docs.condorcet.io/book/3.AsPhpLibrary/9.ExtendingCondorcet/1.CreateNewVoteMethod)
- [Module Skeleton Template](https://github.com/CondorcetVote/Condorcet_Modules_Skeletons)

Main Features
-------------

[](#main-features)

- **Complete Election Management**

    - Handle the full election cycle: candidate registration, vote collection, result calculation
    - Support for vote ordering, tagging, deletion, and result simulation
    - Multiple input formats (string, JSON, objects)
    - Import/export support for Condorcet Election Format, Debian Format, David Hill Format
    - Integrity verification through checksumming
    - Serialization and data export for storage
    - User-friendly features (vote validation, anti-spam, human-readable results)
- **Comprehensive Results and Statistics**

    - Identify Condorcet Winners, Losers, and Paradoxes
    - Generate complete rankings using various [voting methods](Docs/VotingMethods.md)
    - Detailed statistical analysis of results
    - Support for both complete and partial ballot rankings
    - Vote weighting capabilities
- **Advanced Capabilities**

    - Object-oriented design for flexibility and extendability
    - Dynamic candidate and vote management across multiple elections *(simulate election easily)*
    - External storage drivers for handling massive elections
    - Intelligent caching system *(performance optimization)*
    - Vote constraints
- **Extensibility and Configuration**

    - Extend functionality without modifying core code
    - Create custom vote methods, constraints, and storage drivers
    - Extensive configuration options

Although not primarily designed for maximum performance, Condorcet delivers predictable, linear scaling even with very large elections. While not formally certified, comprehensive test coverage ensures reliable results.

---

Use Condorcet as a command line application
-------------------------------------------

[](#use-condorcet-as-a-command-line-application)

### Install as a command line application

[](#install-as-a-command-line-application)

Available installation methods:

- Native installation from source with Composer
- Standalone PHAR executable file
- Docker image (build or pull)

> **[Installation instructions for command line usage](https://docs.condorcet.io/book/3.AsPhpLibrary/1.Installation)**

### Condorcet Book - Command Line

[](#condorcet-book---command-line)

- [**Usage Examples**](https://docs.condorcet.io/book/2.AsCommandLineApplication/2.QuickExample)
- [**Command Reference**](https://docs.condorcet.io/book/2.AsCommandLineApplication/4.ManPage)

Use Condorcet as a PHP Library
------------------------------

[](#use-condorcet-as-a-php-library)

### Install / Autoloading

[](#install--autoloading)

Uses namespace `\CondorcetPHP\Condorcet`

Installation options:

- Composer (recommended) or any native PSR-4 compatible autoloader
- Native autoloader (included)

> **[Installation instructions for PHP library usage](https://docs.condorcet.io/book/3.AsPhpLibrary/1.Installation)**

### Library Manual

[](#library-manual)

> **[Complete Documentation Book](https://docs.condorcet.io)**

The documentation includes comprehensive examples illustrating the library's capabilities.

### Class &amp; API References

[](#class--api-references)

> **[API Reference](/Docs/api-reference/README.md)**

### PHP Library - Examples

[](#php-library---examples)

**Overview Examples:**

- [General Overview](Examples/1.%20Overview.php) (tour of main features)
- [Advanced Object Management](Examples/1.%20AdvancedObjectManagement.php)

**HTML Output Examples:**

- [Visual examples with HTML output](Examples/Examples-with-html/)

**Specific Examples:**

- [Documentation Book](https://docs.condorcet.io/) contains numerous code examples
- [Managing millions of votes with external database drivers](Examples/Specifics_Examples/use_large_election_external_database_drivers.php)

Performance &amp; Coding Style Considerations
---------------------------------------------

[](#performance--coding-style-considerations)

### Coding Standards:

[](#coding-standards)

The codebase follows PSR-12 with some flexibility, enforced via [CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) through[Laravel Pint](https://github.com/laravel/pint).

### Performance:

[](#performance)

- **Typical Use Case:** Complex scenario with all voting methods, 6 candidates, 2 seats, 1,000 votes
    - Memory usage: under 3MB
    - Execution time (with JIT): under 160ms
    - Execution time (without JIT): under 250ms

Performance varies significantly between voting methods. See [method benchmarks](Benchmarks/History/MethodsBench.md).

**Kemeny-Young Performance:**

- 7 candidates: ~5MB memory, 10ms
- 8 candidates: ~6MB memory, 10ms
- 9 candidates: ~7MB memory, 1.1s
- 10 candidates: ~7MB memory, 14s
- 11 candidates: ~8MB memory, 193s

**Large Elections:**For elections with 50,000+ votes, consider external storage to avoid memory constraints. Condorcet includes a PDO driver that works with standard relational databases to handle hundreds of millions of votes. A simple SQLite implementation is provided.

Custom storage drivers can be implemented for NoSQL or other storage systems.

[See the documentation on handling large elections](https://docs.condorcet.io/book/3.AsPhpLibrary/8.GoFurther/5.GetStartedToHandleMillionsOfVotes)

*Benchmarks run on a modern Linux x64 system with PHP 8.1 (CLI).*

Roadmap for Further Releases
----------------------------

[](#roadmap-for-further-releases)

- Future developments to be announced

Related projects / They use Condorcet
-------------------------------------

[](#related-projects--they-use-condorcet)

> **[List of known projects, add yours!](https://github.com/julien-boudry/Condorcet/discussions/categories/your-condorcet-projects)**

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity100

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95.8% 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 ~30 days

Recently: every ~22 days

Total

145

Last Release

82d ago

Major Versions

v2.2.4 → v3.1.22021-11-23

v2.2.5 → v3.3-rc12022-04-27

v3.4-alpha1 → v4.0-alpha12022-05-25

v4.7.0 → v5.0-rc12025-04-25

v4.7.1 → v5.0.02025-04-30

PHP version history (17 changes)v0.5-beta1PHP &gt;=5.4.3

v0.14.0PHP &gt;=5.5.12

v1.0.0PHP &gt;=5.6

v1.1.0PHP &gt;=7.0.8

v1.2.0PHP &gt;=7.1.0

v1.8.3PHP &gt;=7.1.0 &lt;7.4

v2.1-alpha7PHP &gt;=7.4.0

v2.1-beta3PHP &gt;=7.4.1

v2.2.0PHP &gt;= 7.4.1

v2.2.1PHP ^7.4.1 || ~8.0

v3.0.0PHP ^8

v2.2.3PHP ^7.4.1 || ^8.0

v3.2-rc1PHP ^8.1

v3.1.2PHP 8.0.\* || 8.1.\*

v4.3-rc1PHP ^8.2

v4.7.0PHP ^8.3

v5.0-rc1PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4020317?v=4)[Julien Boudry](/maintainers/julien-boudry)[@julien-boudry](https://github.com/julien-boudry)

---

Top Contributors

[![julien-boudry](https://avatars.githubusercontent.com/u/4020317?v=4)](https://github.com/julien-boudry "julien-boudry (1930 commits)")[![toddy15](https://avatars.githubusercontent.com/u/12176273?v=4)](https://github.com/toddy15 "toddy15 (61 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![Christelle-R](https://avatars.githubusercontent.com/u/7345599?v=4)](https://github.com/Christelle-R "Christelle-R (4 commits)")[![LiamM32](https://avatars.githubusercontent.com/u/12264978?v=4)](https://github.com/LiamM32 "LiamM32 (2 commits)")[![orthographic-pedant](https://avatars.githubusercontent.com/u/14522744?v=4)](https://github.com/orthographic-pedant "orthographic-pedant (2 commits)")[![kynoptic](https://avatars.githubusercontent.com/u/50030280?v=4)](https://github.com/kynoptic "kynoptic (1 commits)")[![cyberkurumin](https://avatars.githubusercontent.com/u/714868?v=4)](https://github.com/cyberkurumin "cyberkurumin (1 commits)")

---

Tags

alternative-voteborda-countcondorcetcondorcet-methodscopelanddodgsonelectionelection-managerelection-pollingelection-reformftptinstant-runoffinstant-runoff-votingkemeny-youngminimaxranked-pairsschulze-methodstvvotevoting-methodsvoteelectionstvranked pairsTidemanCondorcetschulzebordacopelandalternative vote

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/julien-boudry-condorcet/health.svg)

```
[![Health](https://phpackages.com/badges/julien-boudry-condorcet/health.svg)](https://phpackages.com/packages/julien-boudry-condorcet)
```

###  Alternatives

[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

96374.6k23](/packages/friendsoftypo3-content-blocks)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[altis/local-server

Local Server module for Altis

18208.4k2](/packages/altis-local-server)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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