Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I have downloaded it from github but I don't know how to run boxpacker folder in localhost.plase help me

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

You can run the command - composer require dvdoug/boxpacker on your project root directory to install BoxPacker after that you can include it in your php file like this -

`<?php
require_once DIR . '/vendor/autoload.php';

use DVDoug\BoxPacker\Packer;
use DVDoug\BoxPacker\Test\TestBox;  // use your own `Box` implementation
use DVDoug\BoxPacker\Test\TestItem; // use your own `Item` implementation

$packer = new Packer();

/*
 * Add choices of box type - in this example the dimensions are passed in directly via constructor,
 * but for real code you would probably pass in objects retrieved from a database instead
 */
$packer->addBox(new TestBox('Le petite box', 300, 300, 10, 10, 296, 296, 8, 1000));
$packer->addBox(new TestBox('Le grande box', 3000, 3000, 100, 100, 2960, 2960, 80, 10000));

/*
 * Add items to be packed - e.g. from shopping cart stored in user session. Again, the dimensional information
 * (and keep-flat requirement) would normally come from a DB
 */
$packer->addItem(new TestItem('Item 1', 250, 250, 12, 200, true), 1); // item, quantity
$packer->addItem(new TestItem('Item 2', 250, 250, 12, 200, true), 2);
$packer->addItem(new TestItem('Item 3', 250, 250, 24, 200, false), 1);

$packedBoxes = $packer->pack();

echo "These items fitted into " . count($packedBoxes) . " box(es)" . PHP_EOL;
foreach ($packedBoxes as $packedBox) {
    $boxType = $packedBox->getBox(); // your own box object, in this case TestBox
    echo "This box is a {$boxType->getReference()}, it is {$boxType->getOuterWidth()}mm wide, {$boxType->getOuterLength()}mm long and {$boxType->getOuterDepth()}mm high" . PHP_EOL;
    echo "The combined weight of this box and the items inside it is {$packedBox->getWeight()}g" . PHP_EOL;

    echo "The items in this box are:" . PHP_EOL;
    $packedItems = $packedBox->getItems();
    foreach ($packedItems as $packedItem) { // $packedItem->getItem() is your own item object, in this case TestItem
        echo $packedItem->getItem()->getDescription() . PHP_EOL;
    }
}`
You must be logged in to vote
1 reply
@lavanyadandumenu
Comment options

thanks for your information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #336 on September 25, 2022 21:22.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.