PHPackages                             abcaeffchen/sudoku-php - 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. abcaeffchen/sudoku-php

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

abcaeffchen/sudoku-php
======================

Generate random Sudokus of different size and difficulty and check the solution.

1.1.0(3y ago)102809[1 issues](https://github.com/AbcAeffchen/sudoku-php/issues)LGPL-3.0-onlyPHPPHP &gt;=7.4.0

Since Mar 26Pushed 3y ago2 watchersCompare

[ Source](https://github.com/AbcAeffchen/sudoku-php)[ Packagist](https://packagist.org/packages/abcaeffchen/sudoku-php)[ GitHub Sponsors](https://github.com/AbcAeffchen)[ RSS](/packages/abcaeffchen-sudoku-php/feed)WikiDiscussions master Synced 3w ago

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

sudoku-php
==========

[](#sudoku-php)

[![Unit Tests](https://github.com/AbcAeffchen/sudoku-php/actions/workflows/php.yml/badge.svg)](https://github.com/AbcAeffchen/sudoku-php/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/307b08433b654b7c89b431601d0bbb018700420ac1d4c5404c3d5cae006b71c6/68747470733a2f2f706f7365722e707567782e6f72672f616263616566666368656e2f7375646f6b752d7068702f762f737461626c652e737667)](https://packagist.org/packages/abcaeffchen/sudoku-php)[![Total Downloads](https://camo.githubusercontent.com/9c537b5e3a6252d4ab02dcb60a7cfb29863cabe7f8430f9e3c4a8b0e914e0f25/68747470733a2f2f706f7365722e707567782e6f72672f616263616566666368656e2f7375646f6b752d7068702f646f776e6c6f6164732e737667)](https://packagist.org/packages/abcaeffchen/sudoku-php)[![License](https://camo.githubusercontent.com/224fa79ba6b1e0ac82e3f4403501271a37ab686fcdc8de32637efdd6f25fd7c0/68747470733a2f2f706f7365722e707567782e6f72672f616263616566666368656e2f7375646f6b752d7068702f6c6963656e73652e737667)](https://packagist.org/packages/abcaeffchen/sudoku-php)

Genral
------

[](#genral)

Generate random Sudokus of different size and difficulty and check the solution. Features:

- Choose from the following sizes: 4, 9, 16, 25, 36.
- Choose from fife degrees of difficulty.
- Sudokus are reproducible via a integer seed.
- Check if a input is a solution of any Sudoku or a solution to a specific task.
- Solve Sudokus.
- works with PHP 7.4 up to 8.2 (maybe also work with PHP &lt; 7.4, but these versions are not supported anymore)
- backend only, so you can build your own frontend however you like it.

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

[](#installation)

You can install this via composer using

```
{
    "require": {
        "abcaeffchen/sudoku-php": "~1.1.0"
    }
}
```

or just download the `Sudoku.php` file and include it to your project. Make sure to use the namespace `AbcAeffchen\sudoku`.

How to use
----------

[](#how-to-use)

#### Generate a task

[](#generate-a-task)

```
use AbcAeffchen\sudoku\Sudoku;
$task = Sudoku::generate(9, Sudoku::NORMAL);

```

Generates a standard 9x9 Sudoku with normal difficulty. You can use the difficulties `VERY_EASY`, `EASY`, `NORMAL`, `MEDIUM`, `HARD`.

`$task` contains a two dimensional array of integers, where the gaps are set to `null`. You can use

```
list($task,$solution) = Sudoku::generateWithSolution(9, Sudoku::NORMAL)

```

to generate a task and a possible solution. Maybe to give hints?

You can reproduce the Sudoku by providing a seed.

```
$seed = 0;
$task = Sudoku::generate(9, Sudoku::NORMAL, $seed);

```

This way cou could store a seed seed and reproduce the task at any time.
The seed can be any positive integer.

#### Check a solution

[](#check-a-solution)

You can check a solution by using

```
if(Sudoku::checkSolution($solution))
{
    echo 'Nice done!';
}
else
{
    echo 'Try again!';
}

```

If you also want to also check if the solution relates to the task, you can just also provide the task like this:

```
if(Sudoku::checkSolution($solution,$task))
    ...

```

#### Solve Sudokus

[](#solve-sudokus)

This function is used to generate the Sudokus, but you can also use it to solve some you generated by hand (or get it from somewhere else).

```
$solution = Sudoku::solve($task);

```

You only have to make sure, that `$task` is a two dimensional int array containing only numbers from 1 to the size and all gaps contain `null`.

License
-------

[](#license)

Licensed under the LGPL v3.0 License.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

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

Total

2

Last Release

1175d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.1.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/89ca3833853fb413d7aec22e8933b3fe5d9d65398345e3104912c99147e35dd8?d=identicon)[AbcAeffchen](/maintainers/AbcAeffchen)

---

Top Contributors

[![AbcAeffchen](https://avatars.githubusercontent.com/u/5396140?v=4)](https://github.com/AbcAeffchen "AbcAeffchen (20 commits)")

---

Tags

phpsudoku

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/abcaeffchen-sudoku-php/health.svg)

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

###  Alternatives

[contributte/neonizer

Collection of useful scripts for manipulaton with NEON files. Support composer pre-install / post-install events. Set/get parameters, validate files.

14852.4k](/packages/contributte-neonizer)[php-mcp/schema

PHP Data Transfer Objects (DTOs) and Enums for the Model Context Protocol (MCP) schema.

19414.4k4](/packages/php-mcp-schema)

PHPackages © 2026

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