ikidnapmyself / sudoxu
Sudoxu is a simple, headless sudoku grid generator library for PHP.
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.0 || ^12.0
This package is auto-updated.
Last update: 2026-07-26 09:40:35 UTC
README
A simple, headless sudoku grid generator for PHP. It produces a fully-solved grid of a configurable (perfect-square) size, returned as an array, JSON, or a serialized string.
Requirements
- PHP 8.1+
Installation
composer require ikidnapmyself/sudoxu
Usage
use Sudoxu\Sudoku; $sudoku = new Sudoku(); // default 9x9 $json = $sudoku->generate('json'); // JSON string $array = $sudoku->generate('array'); // array $ser = $sudoku->generate('serialize'); // serialized string
Each call returns the grid plus metadata:
[
'sudoku' => [ /* flat array, index = row * size + col */ ],
'limit' => 9,
'result' => ['created_in' => 0.02, 'timestamp' => 1721480000, 'difficulty' => 'N/A'],
]
Other sizes
The size must be a perfect square between 1 and 36 (4, 9, 16, 25, 36):
$mini = (new Sudoku(4))->generate('array'); // or change size on an existing instance $big = (new Sudoku())->set(16)->generate('array');
An unsupported size throws an InvalidArgumentException.
Note: Larger grids (16x16 and up) are CPU- and memory-heavy. Unlike older versions, the library no longer changes
memory_limitor the time limit for you — raise them in your own application if a large grid needs it.
Companion project
sudoxu-app — a front end built on top of this library.
License
MIT