PHPackages                             braienstorm/bin-packer - 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. braienstorm/bin-packer

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

braienstorm/bin-packer
======================

2D bin packing for PHP

v1.0.3(3y ago)029MITPHPPHP ^7.2 || ^8.0

Since Mar 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/BraienStorm/bin-packer)[ Packagist](https://packagist.org/packages/braienstorm/bin-packer)[ RSS](/packages/braienstorm-bin-packer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

bin-packer
==========

[](#bin-packer)

I made it for a metal cutting company. This code selects the appropriate raw metal sheets for cutting. Original idea Padam87 link: 2D bin packing for PHP, with rotation.

Usage
-----

[](#usage)

### Basic

[](#basic)

```
$Boxes = [
    new Block(100, 100),
    new Block(300, 100),
];
$bin = new Bin(1500,3000);
$bin->insertManyBlock($Boxes);
```

#### How to get unused Boxes

[](#how-to-get-unused-boxes)

You will get all unused Block as a array.

```
$unusedBoxes = $bestBin->getUnpackedBlocks()
```

### How to get used boxes

[](#how-to-get-used-boxes)

You can get the node tree and evaluate it with a function

```
    $node = $bin->getNode();
    getUsedBlock($node);

    function getUsedBlock(\Node $node)
    {
        if($node == null)
            return;
        if($node->isUsed())
        {
            print_r($node->getBlock());
            $this->getUsedBlock($node->getRight());
            $this->getUsedBlock($node->getDown());
        }
    }
```

### How to get score

[](#how-to-get-score)

```
    $sc = $bestBin->getStatistic();

Array
(
    [score] => 0.72624 // [used] / ([binWidth]*[binHeight])
    [used] => 2269500  // used arrea
    [free] => 855500   // free arrea
    [binWidth] => 2500
    [binHeight] => 1250
)
```

### Visualiser

[](#visualiser)

```
        $visualizer = new Visualizer();
        $image = $visualizer->visualize($bin);
        $image->setFormat('jpg');
        $image->writeImage('bin.jpg');
```

[![visualizer](docs/bin.jpg)](docs/bin.jpg)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

4

Last Release

1160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a96f58dbfad5bcd7cdf698878fcb83ba6eaa8081e9b94cf79a1f45f80a209ec?d=identicon)[BraienStorm](/maintainers/BraienStorm)

---

Top Contributors

[![BraienStorm](https://avatars.githubusercontent.com/u/22961434?v=4)](https://github.com/BraienStorm "BraienStorm (11 commits)")

### Embed Badge

![Health badge](/badges/braienstorm-bin-packer/health.svg)

```
[![Health](https://phpackages.com/badges/braienstorm-bin-packer/health.svg)](https://phpackages.com/packages/braienstorm-bin-packer)
```

###  Alternatives

[petrabarus/yii2-googleplacesautocomplete

Google Places Auto Complete input widget for Yii2

106.4k](/packages/petrabarus-yii2-googleplacesautocomplete)

PHPackages © 2026

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