Closed ghost closed 8 years ago
Hi
If you're not using Composer, I recommend installing the PSR log interface manually - that way upgrading BoxPacker to a newer version the future won't involve manually modifying code.
The relevant repo is here: https://github.com/php-fig/log
You only need to specify the box sizes - the library assumes you're not going to run out
Thanks for your reply. You've done a great job on this library.
Do you have any donation fund ? I building an eCommerce module which I will be using this in and I'd be happy to donate.
Additionally, if you want I have a small task to implement your library and if your free Id be happy to contract you (pay you for your time). Thanks again for some great work you did
That's kind, but this project was done as a personal challenge really - I couldn't find anyone else who had done this kind of thing in PHP so I thought I'd go ahead and do it.
Thanks again though, Doug
no problem, Does the packer always fit all items into boxes, in what situation would the packer() not pack an item.
Yes, it will keep going until every single item is packed into a box. The only situation that won't happen is if you ask it do the impossible and have an item that is bigger than all the box choices you supply (or heavier than the box maximum weight). In that situation, you'll get a RuntimeException
as there's nothing else it can do.
Thanks again. The library is working almost without fail! Although I do have a request.
1
I have been testing this when there are no available Boxes for the Item to fit into I get an Exception
.
Rather than creating an exception for this (as you mentioned above), I feel its probably not a good idea for production use. Having to deal with exceptions gracefully is far better than a raw exception.
Could the system at this point place the item in a separate list called "$packer->unPackedItemList"
Then each Item in this list could also have a message of why, The item was too heave for any boxes" Or the item HWL
does not fit in any item.
For people like myself who want to implement this in a eCommerce system, could then choose to deal with these items differently.
2
Also, when you dump the packedBox
it shows the remainingWeight
correctly but the weght
is NULL
Also, to make this compatible with 5.3 of PHP you could use array() rather than $return = [].
Otherwise, perhaps make a branch called 5.3 compatible. This will be useful for some people still running 5.3
Im currently running 5.4 but I came across the error with a friend of mine who is running the 5.3 PHP
PHP5.3 is EOL, so I've got no plans to backport any features.
I'll have a think though about adding in an "unpacked" list - I can see how it might be useful, but it would be an API change (currently running to completion means you know all boxes were packed).
ok cool no prob. Im running 5.4 anyway.
Its all implemented and working well with the new updates. A few minor glitches tho.
I have a list of5 available boxes that theoretically can store wine bottles.
Box 1: Holds 1 Bottle Box 2: Holds 2 Bottles Box 3: Holds 3 Bottles Box 4: Holds 6 Bottles Box 5: Holds 12 Bottles
When I add 4 bottles, it yeilds the BOX 4, which is correct. When I add 7 bottles it yeilds BOX 5, where I would expect it to provide 2 boxes BOX 4 + BOX 1
I will forward all my test results if you like.
That's right, because the assumption is that 2 boxes will cost you more to ship than a single box will - you have a situation where that's not true?
Closing for lack of update
Hi, I wasn't sure how to contact you otherwise, but I'm trying to implement this in my ci application.
I don't have PSR or PHPUnit and whenI try to use this library I get an error because PHP cant find LogAwareInterface.
I removed the code for the logger and it seems to be ok, I used require() statements instead of the autoload feature because Im using CI.
Finally, do I have to know how many Boxes to create, or do I just define the box sizes available.
cheers