This package is abandoned and no longer maintained. No replacement package was suggested. PHP API

0.5 2016-07-21 10:25 UTC

This package is auto-updated.

Last update: 2022-02-01 12:52:25 UTC


Build Status Scrutinizer Code Quality Test Coverage Code Climate StyleCI Latest Stable Version Total Downloads License

This library acts as a PHP wrapper around the API available at

WARNING: this package is abandoned and will not receive support. It will stay available on GH.

Table Of Content

  1. Requirements
  2. Installation
  3. Example
  4. License


This library uses PHP 5.5+.

To use the API Wrapper, you have to request an access key from For every request, you will have to provide the username & API Key.

Note: this service is NOT free of usage.


It is recommended that you install the library through composer. To do so, run the Composer command to install the latest stable version of the API wrapper:

composer require stefandoorn/3dbinpacking-php-api


// Build packing request
$request = new \BinPacking3d\Entity\Request();

$bin = new \BinPacking3d\Entity\Bin();

// Item
$item = new \BinPacking3d\Entity\Item();
$item->setProduct(['product_id' => 1]);

// Set extra info
$request->setApiKey('API KEY');

// Perform request and get results
$boxes = $packIntoMany->run();

// Process result, in here we get all the packed boxes including the items per box
foreach ($boxes->yieldBins() as $packedBox) {
    // Get weight of box
    $weight = $packedBox->getUsedWeight();

    // Get dimensions
    $height = $packedBox->getOuterHeight();
    $width = $packedBox->getOuterWidth();
    $depth = $packedBox->getOuterDepth();

    // Get identifier
    $identifier = $packedBin->getIdentifier();

    // Get items in this box
    foreach ($packedBox->yieldItems() as $item) {
    	// Get additional product data supplied (e.g. IDs, SKUs, etc)
    	$product = $item->getProduct();

    	// Add to database etc...

Optional you can add a PSR-3 compatible logger to the Request object:

$log = new \Monolog\Logger('binpacking');
$log->pushHandler(new \Monolog\Handler\StreamHandler('binpacking.log', \Monolog\Logger::DEBUG));

Optional you can add a Cache driver compatible with doctrine/cache, e.g.:

$cacheDriver = new \Doctrine\Common\Cache\RedisCache();
$redis = new Redis;

License API Wrapper is licensed under The MIT License (MIT).