Download the PHP package daika7ana/smallest-box without Composer
On this page you can find all versions of the php package daika7ana/smallest-box. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download daika7ana/smallest-box
More information about daika7ana/smallest-box
Files in daika7ana/smallest-box
Download daika7ana/smallest-box
More information about daika7ana/smallest-box
Files in daika7ana/smallest-box
Vendor daika7ana
Package smallest-box
Short Description Calculate the smallest rectangular box (W x L x H) that fits a set of rectangular items, using axis-aligned 3D bin packing with rotation support.
License GPL-3.0-or-later
Package smallest-box
Short Description Calculate the smallest rectangular box (W x L x H) that fits a set of rectangular items, using axis-aligned 3D bin packing with rotation support.
License GPL-3.0-or-later
Please rate this library. Is it a good library?
Informations about the package smallest-box
smallest-box
[](https://github.com/daika7ana/smallest-box/actions/workflows/ci.yml)
[](https://www.php.net/)
[](docs/testing.md)
[](phpstan.neon)
[](LICENSE)
Calculate the smallest rectangular box that fits a set of rectangular items, using axis-aligned 3D bin packing with rotation support.
Zero dependencies, fully typed, three packing algorithms, and rotation-aware candidate generation.
Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Packing Algorithms
- Custom Sort & Pack Orders
- Testing
- Documentation
Features
Core Strengths
- ✅ Smallest Box Finding — Greedy 3D bin packing with rotation support
- ✅ Six Axis-Aligned Rotations — Items tested in all orientations for optimal fit
- ✅ Three Packing Algorithms — Guillotine, MaxRects, and ExtremePoint
- ✅ Custom Sort & Pack Orders — Fine-tune item ordering via closures
- ✅ Fluent API — Build item lists incrementally with
add(),remove(),clear() - ✅ Immutable Value Objects —
ItemandBoxwith type-safe accessors - ✅ Static Analysis with PHPStan — Strict type checks across the codebase
- ✅ Zero Dependencies — Only requires PHP 7.4+
Perfect For
- 🎯 Logistics and shipping box optimisation
- 🎯 Warehouse packing calculations
- 🎯 3D layout and spatial planning
- 🎯 Any scenario needing the smallest bounding box for rectangular items
Requirements
- PHP 7.4+
Installation
Via Composer
Quick Start
Pass items directly
Build item list incrementally
Choose a packing algorithm
That's it! You've got the smallest box that fits all your items.
Packing Algorithms
| Algorithm | Efficiency | Speed | Best For |
|---|---|---|---|
ALGO_GUILLOTINE (default) |
~65% | Fast | Uniform items, speed-critical |
ALGO_EXTREMEPOINT |
~75% | Medium | Balanced efficiency and speed |
ALGO_MAXRECTS |
~100% | Slower | Diverse items, best fit |
How It Works
- Sort items by multiple heuristics (volume, dimensions, footprint).
- Generate candidate box dimensions from item dimension permutations and sums.
- Test each candidate with the selected packing algorithm and all six rotations.
- Return the smallest box that successfully fits all items.
Custom Sort & Pack Orders
Fine-tune packing behaviour for your specific use case:
Custom orders are tried after the built-in ones. Both methods support fluent chaining.
Testing
Run Static Analysis
PHPStan is configured via phpstan.neon and analyses the src/ directory.
Run Code Style Checks
Run Full Test Suite
Run The Same Checks As CI
Available Composer scripts:
composer pint— Check code style (Laravel Pint)composer stan— Run static analysis (PHPStan)composer test— Run the test suite (PHPUnit)composer ci— Run all checks in sequence
Documentation
| Guide | Purpose |
|---|---|
| 📖 Usage & Examples | Working examples and patterns |
| 🔧 Installation | Detailed setup instructions |
| 📋 API Reference | Complete class and method reference |
| ⚙️ Algorithm Details | How the packing algorithms work |
Made with ❤️
**Questions?** [Check the docs](docs/usage.md) or [open an issue](../../issues)
All versions of smallest-box with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.4
The package daika7ana/smallest-box contains the following files
Loading the files please wait ...