PackageTrack
Sign in Get early access

dvdoug/boxpacker

An implementation of the 3D (actually 4D) bin packing/knapsack problem (aka creating parcels by putting items into boxes)

4.3.0 3.0M downloads/mo #3178 most downloaded on Packagist dvdoug/BoxPacker

What this package is like to depend on

Last release 14 days ago

09 Aug 2026

Ships fairly regularly

a new release about every 5 months

Nearly every release is documented

notes for 93 of 93 stable releases

Nothing withdrawn

no release was ever pulled

13 years old

93 releases · first in 2013

2 releases in the last 12 months

see the full history below

Release timeline

93 releases · Jul 2013 to Aug 2026
2014 2016 2018 2020 2022 2024 2026
Release Pre-release

Releases

latest 60 of 93
  1. 4.3.0 09 Aug 2026
    Release notes

    Changed

    • Improved efficiency in packing

    Fixed

    • In some rare cases WeightRedistributor would silently drop items
    • Sort linked items to give them the best chance of being packed together, to prevent no boxes being found due to the items being out of order.
    Open source →
    Release notes

    Changed

    • Improved efficiency in packing

    Fixed

    • In some rare cases WeightRedistributor would silently drop items
    • Sort linked items to give them the best chance of being packed together, to prevent no boxes being found due to the items being out of order.
    Open source →
  2. 4.2.0 05 Jul 2026
    Release notes

    Added

    • A mechanism to allow forcing certain items to be packed together [RubenKluft]
    Open source →
    Release notes

    Added

    • A mechanism to allow forcing certain items to be packed together [RubenKluft]
    Open source →
  3. 4.1.1 21 Jul 2025
    Release notes

    Fixed

    • In some cases the maximum weight of a box was not respected
    • Sometimes boxes were not ordered canonically
    • Visualisation links did not encode the query params
    Open source →
    Release notes

    Fixed

    • In some cases the maximum weight of a box was not respected
    • Sometimes boxes were not ordered canonically
    • Visualisation links did not encode the query params
    Open source →
  4. 4.1.0 06 Feb 2025
    Release notes

    Added

    • A mechanism to allow a proactive timeout on v. large packings rather than run to completion
    Open source →
    Release notes

    Added

    • A mechanism to allow a proactive timeout on v. large packings rather than run to completion
    Open source →
  5. 4.0.1 01 Apr 2024
    Release notes

    Changed

    • Improved efficiency in packing
    Open source →
    Release notes

    Changed

    • Improved efficiency in packing
    Open source →
  6. 4.0.0 04 Dec 2023
    Release notes

    Added

    • Added new enumeration Rotation with values Never, KeepFlat and BestFit
    • Added new getAllowedRotation() method to the Item interface to replace getKeepFlat(). This should return
      one of the new Rotation enum values
    • Added new generateVisualisationURL() method to PackedBox and PackedBoxList. This will generate a custom URL for
      a visualisation you can access via the BoxPacker website
    • Added new packAllPermutations() method to Packer to calculate all possible box combinations
    • Added throwOnUnpackableItem() to Packer to control if an exception is thrown (or not) if an unpackable item is
      found (defaults to true, consistent with previous behaviour)
    • Added getUnpackedItems() to Packer to retrieve the list of items that could not be packed (only applicable if
      exceptions are disabled)
    • PackedBox now has readonly public properties ->box and ->item
    • PackedItem now has readonly public properties ->item, ->x, ->y, ->z, ->width, ->length, ->depth

    Changed

    • Minimum PHP version is now 8.2
    • Exceptions are now in the DVDoug\BoxPacker\Exception namespace (previously DVDoug\BoxPacker)
    • The signature of the ->canBePacked method on the ConstrainedPlacementItem interface has been changed to replace the
      first two arguments(Box $box, PackedItemList $alreadyPackedItems) with PackedBox $packedBox. This allows
      callbacks to make use of the helper methods provided on PackedBox. Access to the box and items can be done via
      $packedBox->box and $packedBox->items
    • NoBoxesAvailableException now has a ->getAffectedItems() method instead of ->getItem(). This should allow
      improved handling of the exception inside calling applications when multiple items cannot be packed

    Removed

    • Removed getBox() and getItems() from PackedBox. Use the new public properties instead
    • Removed ->getItem(), ->getX(), ->getY(), ->getZ(), ->getWidth(), ->getLength() and ->getDepth()
      from PackedItem. Use the new public properties instead
    • Removed deprecated ConstrainedItem. You should use ConstrainedPlacementItem as a replacement
    • Removed getKeepFlat() from the Item interface
    • Removed InfalliblePacker. You can now get the same behaviour by calling ->throwOnUnpackableItem(false) and
      ->getUnpackedItems() on the main Packer class
    Open source →
    Release notes

    Added

    • Added new enumeration Rotation with values Never, KeepFlat and BestFit
    • Added new getAllowedRotation() method to the Item interface to replace getKeepFlat(). This should return one of the new Rotation enum values
    • Added new generateVisualisationURL() method to PackedBox and PackedBoxList. This will generate a custom URL for a visualisation you can access via the BoxPacker website
    • Added new packAllPermutations() method to Packer to calculate all possible box combinations
    • Added throwOnUnpackableItem() to Packer to control if an exception is thrown (or not) if an unpackable item is found (defaults to true, consistent with previous behaviour)
    • Added getUnpackedItems() to Packer to retrieve the list of items that could not be packed (only applicable if exceptions are disabled)
    • PackedBox now has readonly public properties ->box and ->item
    • PackedItem now has readonly public properties ->item, ->x, ->y, ->z, ->width, ->length, ->depth

    Changed

    • Minimum PHP version is now 8.2
    • Exceptions are now in the DVDoug\BoxPacker\Exception namespace (previously DVDoug\BoxPacker)
    • The signature of the ->canBePacked method on the ConstrainedPlacementItem interface has been changed to replace the first two arguments(Box $box, PackedItemList $alreadyPackedItems) with PackedBox $packedBox. This allows callbacks to make use of the helper methods provided on PackedBox. Access to the box and items can be done via $packedBox->box and $packedBox->items
    • NoBoxesAvailableException now has a ->getAffectedItems() method instead of ->getItem(). This should allow improved handling of the exception inside calling applications when multiple items cannot be packed

    Removed

    • Removed getBox() and getItems() from PackedBox. Use the new public properties instead
    • Removed ->getItem(), ->getX(), ->getY(), ->getZ(), ->getWidth(), ->getLength() and ->getDepth() from PackedItem. Use the new public properties instead
    • Removed deprecated ConstrainedItem. You should use ConstrainedPlacementItem as a replacement
    • Removed getKeepFlat() from the Item interface
    • Removed InfalliblePacker. You can now get the same behaviour by calling ->throwOnUnpackableItem(false) and ->getUnpackedItems() on the main Packer class
    Open source →
  7. 3.12.1 02 Dec 2023
    Release notes

    Fixed

    • Restored ability to copy/paste the samples from the docs into a non-dev installation
    Open source →
    Release notes

    Fixed

    • Restored ability to copy/paste the samples from the docs into a non-dev installation
    Open source →
  8. 3.12.0 29 Jul 2023
    Release notes

    Changed

    • Improved efficiency in packing

    Removed

    • Support for PHP 7.1, 7.2 and 7.3
    Open source →
    Release notes

    Changed

    • Improved efficiency in packing

    Removed

    • Support for PHP 7.1, 7.2 and 7.3
    Open source →
  9. 3.11.0 04 Feb 2023
    Release notes

    Changed

    • Calling json_encode() on a PackedBox or PackedItem now additionally serialises the entire underlying
      Box/Item where those objects also implement JsonSerializable. Previously the serialisation only included the
      key values from the Box/Item interfaces themselves.
    Open source →
    Release notes

    Changed

    • Calling json_encode() on a PackedBox or PackedItem now additionally serialises the entire underlying Box/Item where those objects also implement JsonSerializable. Previously the serialisation only included the key values from the Box/Item interfaces themselves.
    Open source →
  10. 3.10.0 10 Sep 2022
    Release notes

    Added

    • Added ItemSorter, BoxSorter and PackedBoxSorter to allow calling applications to have better control over
      sorting decisions
    • Added beStrictAboutItemOrdering() to Packer and VolumePacker
    Open source →
    Release notes

    Added

    • Added ItemSorter, BoxSorter and PackedBoxSorter to allow calling applications to have better control over sorting decisions
    • Added beStrictAboutItemOrdering() to Packer and VolumePacker
    Open source →
  11. 3.9.4 21 Oct 2021
    Release notes

    Changed

    • psr/log compatibility changed from ^1.0 to ^1.0||^2.0||^3.0
    Open source →
  12. 3.9.3 26 Sep 2021
    Release notes

    Fixed

    • PHP8.1 deprecations
    Open source →
  13. 3.9.2 04 Jul 2021
    Release notes

    Added

    • Optional second parameter $qty to ItemList->insert()

    Fixed

    • Fixed issue where available width for an item could be miscalculated

    Changed

    • Improved memory usage
    Open source →
  14. 3.9.1 05 May 2021
    Release notes

    Fixed

    • Fixed issue where available width for an item could be miscalculated at the far end of a box

    Changed

    • Improved efficiency in packing in the vertical direction
    Open source →
  15. 3.9.0 14 Mar 2021
    Release notes

    Added

    • Added packAcrossWidthOnly() to VolumePacker for scenarios where the container will be side-loaded rather than top-loaded (e.g. truck loading)
    • Added getWeight() helper method to PackedItemList
    • Experimental visualisation tool has been added to the repo. All aspects of the tool are subject to change.

    Changed

    • Improved efficiency in packing
    Open source →
  16. 3.8.0 26 Jan 2021
    Release notes

    Added

    • Added fromArray() helper method to BoxList to make bulk add easier [bram123]
    Open source →
  17. 3.7.0 01 Jan 2021
    Release notes

    Added

    • Added getVolume() helper method to PackedItemList
    Open source →
  18. 3.6.2 28 Sep 2020
    Release notes

    Added

    • Support for PHP 8.0
    Open source →
  19. 3.6.1 11 Jun 2020
    Release notes

    Fixed

    • Fixed situation where internal WorkingVolume could be passed into a constraint callback, rather than the calling application's own Box
    • Fixed issue where the list of previously packed items passed into a constraint callback was not correct
    Open source →
  20. 3.6.0 26 Apr 2020
    Release notes

    Changed

    • Improved efficiency in packing and weight distribution
    • Major internal refactoring. The public-facing API did not change in any incompatible ways, but if you extended any of the @internal classes or made use of @internal methods you may be affected.
    • Bail out earlier in the packing process where an item doesn't fit [colinmollenhour]

    Fixed

    • Fixed potential issue where internal sort consistency wasn't always correct
    • Fixed potential issue where custom constraints might not be fully respected
    • Avoid divide by zero error when a box is specified to have a depth of 0mm (e.g. 2D packing)
    • Better docblocks [colinmollenhour]
    Open source →
  21. 3.5.2 02 Feb 2020
    Release notes

    Changed

    • Further optimisation when packing a large number of items
    Open source →
  22. 3.5.1 30 Jan 2020
    Release notes

    Changed

    • Optimisation when packing a large number of identical items
    Open source →
  23. 3.5.0 26 Jan 2020
    Release notes

    Added

    • Added a new interface LimitedSupplyBox extends Box for situations where there are restrictions on the number of a box type available for packing Items into. The interface contains 1 additional method getQuantityAvailable().
    • Added new exception NoBoxesAvailableException which is thrown when an item cannot be packed due to suitable boxes not being available (e.g. when the new functionality is used and the quantity available is insufficient). The existing ItemTooLargeException which is thrown when an item is too large to fit into any of the supplied box types at all (regardless of quantity) still exists, and now extends from NoBoxesAvailableException as a special case

    Changed

    • Improved efficiency in packing and weight distribution
    • The ItemList passed to VolumePacker's constructor is now cloned before usage, leaving the passed-in object unaffected. Previously this was used as a working dataset. The new behaviour aligns with the existing behaviour of Packer

    Fixed

    • Fixed issue where internal sort consistency wasn't always correct
    • Some debug-level logging wasn't logging correctly
    Open source →
  24. 3.4.1 21 Dec 2019
    Release notes

    Changed

    • Speed improvements
    Open source →
  25. 3.4.0 09 Sep 2019
    Release notes

    Added

    • Added ability to specify that items are pre-sorted when creating an ItemList from an array

    Changed

    • Significant speed improvements when dealing with a large number of items
    Open source →
  26. 3.3.0 14 Jul 2019
    Release notes

    Added

    • Added ConstrainedPlacementItem as a more powerful version of ConstrainedItem

    Changed

    • Improved box selection for certain cases
    • Speed improvements
    • Increased detail in debug-level logging

    Deprecated

    • ConstrainedItem is now deprecated. Use ConstrainedPlacementItem instead
    Open source →
  27. 3.2.2 20 Nov 2018
    Release notes

    Fixed

    • Fixed divide by zero warning when attempting to pack an item with 0 depth
    Open source →
  28. 3.2.1 13 Nov 2018
    Release notes

    Fixed

    • Fixed issue where internal sort consistency wasn't always correct
    Open source →
  29. 3.2.0 12 Nov 2018
    Release notes

    Added

    • Added getVolume() helper method to PackedItem [Cosmologist]

    Changed

    • Improved item orientation selection for better packing
    • Minor refactorings for code clarity
    Open source →
  30. 3.1.3 15 Jun 2018
    Release notes

    Changed

    • Worked around an PHP recursion issue when comparing 2 Items.
    Open source →
  31. 3.1.2 13 Jun 2018
    Release notes

    Changed

    • Fixed typos in documentation code samples
    Open source →
  32. 3.1.1 03 Jun 2018
    Release notes

    Changed

    • Tweaked composer configuration to make it easier to run the samples in the documentation
    • Minor speed improvements
    Open source →
  33. 3.1.0 19 Feb 2018
    Release notes

    Added

    • Optional 'Infallible' mode of packing to not throw an exception on error (e.g. item too large) but to continue packing the other items

    Changed

    • Improved stability algorithm
    • Improved box selection for certain cases
    • Some internal refactoring
    Open source →
  34. 3.0.1 01 Jan 2018
    Release notes

    Added

    • Declare PackedBoxList as implementing Countable

    Changed

    • Improved item orientation selection for better packing
    Open source →
  35. 3.0.0 23 Oct 2017
    Release notes

    Added

    • Introduced PackedItems which are a wrapper around Items with positional and dimensional information (x, y, z co-ordinates of corner closest to origin, width/length/depth as packed)
    • Added method to set threshold at which weight redistribution is disabled

    Changed

    • PackedBox now contains a PackedItemList of PackedItems (rather than an ItemList of Items)
    • ConstrainedItem->canBePackedInBox() now takes a PackedItemList of PackedItems (rather than an ItemList of Items)
    • BoxList, ItemList, PackedBoxList have been altered to implement the Traversable interface rather than extend SplHeap directly so that any future changes to the internals will not need an API change
    • Minimum PHP version is now 7.1

    Removed

    • HHVM support now that project has a stated goal of no longer targeting PHP7 compatibility
    Open source →
  36. 2.7.2 28 Sep 2020
    Release notes

    Added

    • Support for PHP 8.0

    Removed

    • Making the test suite compatible with PHP 8.0 has necessitated the removal of support for PHP 5.4 - 7.0 (see note below)

    v2 of BoxPacker is in maintenance mode only, all users are encouraged to update to v3. This release has been made primarily to certify PHP 8 compatibility, unless an egregious bug is discovered (e.g. a physically impossible packing) this will probably be the last v2 release that includes any changes to core packing logic. (Any) further releases are intended to be limited to compatibility with future PHP versions.

    Open source →
  37. 2.7.1 11 Jun 2020
    Release notes

    Fixed

    • Fixed situation where internal WorkingVolume could be passed into a constraint callback, rather than the calling application's own Box
    • Fixed issue where the list of previously packed items passed into a constraint callback was not correct
    Open source →
  38. 2.7.0 24 Apr 2020
    Release notes

    Changed

    • Improved efficiency in packing and weight distribution
    • Major internal refactoring. The public-facing API did not change in any incompatible ways, but if you extended any of the @internal classes or made use of @internal methods you may be affected.
    • Bail out earlier in the packing process where an item doesn't fit [colinmollenhour]

    Fixed

    • Fixed potential issue where custom constraints might not be fully respected
    • Avoid divide by zero error when a box is specified to have a depth of 0mm (e.g. 2D packing)
    Open source →
  39. 2.6.5 02 Feb 2020
    Release notes

    Changed

    • Further optimisation when packing a large number of items
    Open source →
  40. 2.6.4 30 Jan 2020
    Release notes

    Changed

    • Optimisation when packing a large number of identical items
    Open source →
  41. 2.6.3 26 Jan 2020
    Release notes

    Changed

    • Improved efficiency in packing and weight distribution
    • The ItemList passed to VolumePacker's constructor is now cloned before usage, leaving the passed-in object unaffected. Previously this was used as a working dataset. The new behaviour aligns with the existing behaviour of Packer

    Fixed

    • Fixed issue where internal sort consistency wasn't always correct
    • Some debug-level logging wasn't logging correctly
    Open source →
  42. 2.6.2 21 Dec 2019
    Release notes

    Changed

    • Speed enhancements
    Open source →
  43. 2.6.1 15 Sep 2019
    Release notes

    Changed

    • Speed enhancements
    Open source →
  44. 2.6.0 14 Jul 2019
    Release notes

    Added

    • Added ConstrainedPlacementItem as a more powerful version of ConstrainedItem

    Changed

    • Improved box selection for certain cases
    • Speed improvements
    • Increased detail in debug-level logging

    Deprecated

    • ConstrainedItem is now deprecated. Use ConstrainedPlacementItem instead
    Open source →
  45. 2.5.0 20 Nov 2018
    Release notes

    Added

    • Backported positional data support from v3 via new getPackedItems() method on PackedBox

    Fixed

    • Fixed divide by zero warning when attempting to pack an item with 0 depth
    Open source →
  46. 2.4.8 13 Nov 2018
    Release notes

    Fixed

    • Fixed issue where internal sort consistency wasn't always correct
    Open source →
  47. 2.4.7 12 Nov 2018
    Release notes

    Changed

    • Improved item orientation selection for better packing
    • Minor refactorings for code clarity
    Open source →
  48. 2.4.6 15 Jun 2018
    Release notes

    Changed

    • Worked around an PHP recursion issue when comparing 2 Items.
    Open source →
  49. 2.4.5 03 Jun 2018
    Release notes

    Changed

    • Tweaked composer configuration to make it easier to run the samples in the documentation
    Open source →
  50. 2.4.4 25 Feb 2018
    Release notes

    Changed

    • Improved stability algorithm
    • Improved box selection for certain cases
    • Some internal refactoring
    Open source →
  51. 2.4.3 01 Jan 2018
    Release notes

    Changed

    • Improved item orientation selection for better packing
    Open source →
  52. 2.4.2 23 Oct 2017
    Release notes

    Changed

    • Previously 2 distinct item types could be mixed when sorting items for packing if they had identical physical dimensions. Now if all dimensions are identical, items are sorted by description so that they are kept together
    Open source →
  53. 2.4.1 04 Sep 2017
    Release notes

    Fixed

    • Used/remaining space calculations were sometimes offset by 90 degrees leading to confusing numbers
    Open source →
  54. 2.4.0 13 Aug 2017
    Release notes

    Changed

    • Significant reworking of core packing logic to clarify concepts used

    Fixed

    • Fixed issue where getUsed[Width|Length|Depth]() could sometimes return an incorrect value
    Open source →
  55. 2.3.2 06 Aug 2017
    Release notes

    Changed

    • In some cases, complex user-added constraints via BoxPacker\ConstrainedItem were not being obeyed
    • Test classes refactored to be autoloadable
    • Some internal refactoring
    Open source →
  56. 2.3.1 15 Apr 2017
    Release notes

    Changed

    • PackedBox->getUsedDepth() could incorrectly return a value of 0 in some situations
    Open source →
  57. 2.3.0 09 Apr 2017
    Release notes

    Added

    • Add callback system for more complex constraints e.g. max number of hazardous items in a box. To take advantage of the additional flexibility, implement BoxPacker\ConstrainedItem rather than BoxPacker\Item

    Changed

    • Some internal refactoring
    Open source →
  58. 2.2.1 12 Mar 2017
    Release notes

    Added

    • Added getItem() to ItemTooLargeException to make it programmatically possible determine what the affected item is
    Open source →
  59. 2.2.0 06 Mar 2017
    Release notes

    Added

    • The previous limitation that all items were always packed flat has been removed
    • A specific ItemTooLargeException exception is now thrown when an item cannot fit inside any boxes rather than a generic \RuntimeException
    Open source →
  60. 2.1.0 07 Jan 2017
    Release notes

    Added

    • Added getUsed[Width|Length|Depth]() on PackedBoxes to allow for better visibility into space utilisation

    Changed

    • Equal distribution of weight is now turned off when the number of boxes becomes large as it provides very little to no benefit at that scale and is slow to calculate
    • Various optimisations and internal refactorings
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive