Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prhost/packer
Library to organize and package your products intelligently
https://github.com/prhost/packer
composer-library package packer php php7
Last synced: 3 months ago
JSON representation
Library to organize and package your products intelligently
- Host: GitHub
- URL: https://github.com/prhost/packer
- Owner: prhost
- License: mit
- Created: 2019-01-30T15:14:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T13:41:59.000Z (over 5 years ago)
- Last Synced: 2024-09-29T20:22:07.799Z (3 months ago)
- Topics: composer-library, package, packer, php, php7
- Language: PHP
- Size: 58.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PACKER (BETA)
Library to organize and package your products intelligently![Packer](packer.jpg)
## Example
```php
require_once '../vendor/autoload.php';use Prhost\Packer\Classes\ConveyorBelt;
use Prhost\Packer\Classes\Package;
use Prhost\Packer\Classes\Worker;
use Prhost\Packer\Classes\Product;//creating packages
$package1 = new Package();
$package1
->setIdentifier('package1')
->setWidth(20)
->setHeight(20)
->setLength(30)
->setWeight(1)
->setMaxWeight(30); //no define to disable check max weight
$package2 = new Package();$package2
->setIdentifier('package2')
->setWidth(20)
->setHeight(20)
->setLength(20)
->setWeight(1);//create product
$product1 = new Product();
$product1
->setIdentifier('product1')
->setQuantity(1)
->setWeight(20)
->setLength(10)
->setWidth(30)
->setHeight(10)
->enableEitherSideIsUp();
$product2 = new Product();$product2
->setIdentifier('product2')
->setQuantity(13)
->setWeight(10)
->setLength(10)
->setWidth(30)
->setHeight(10);//on conveyorbelt
$conveyorBelt = new ConveyorBelt();
$conveyorBelt
->put($product1)
->put($product2);$worker = new Worker();
$worker
->setConveyorBelt($conveyorBelt)
->setPackages([
$package1,
$package2,
]);$volumes = $worker->arrange();
echo "
Total volumes: " . count($volumes) . '
';
foreach ($volumes as $volume) {
var_dump($volume);
echo "
==========================================================
";
}//Left over products on the conveyorbelt
echo "
Left over products on the conveyorbelt: " . $worker->getConveyorBelt()->count() . '
';
foreach ($worker->getConveyorBelt()->getProducts() as $product) {
var_dump($product);
echo "
==========================================================
";
}
```