PHPackages                             ggggino/warehouse-path - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ggggino/warehouse-path

ActiveLibrary

ggggino/warehouse-path
======================

Find the shortest path to retrieve all the objects in the own location

1.1.0(7y ago)09MITPHPPHP ^7.0

Since Feb 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/GGGGino/WarehousePath)[ Packagist](https://packagist.org/packages/ggggino/warehouse-path)[ RSS](/packages/ggggino-warehouse-path/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (4)Used By (0)

GGGGinoWarehousePath
====================

[](#gggginowarehousepath)

> Find the shortest path to retrieve all the objects in the own location

[![Build Status](https://camo.githubusercontent.com/0e9eeda89bac11c1c4ca7d836087d3bfe08967c33baaa98c94db6db81b08fa4b/68747470733a2f2f7472617669732d63692e636f6d2f47474747696e6f2f57617265686f757365506174682e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/GGGGino/WarehousePath)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8650217edbd6fdb753d2f4e81843dbc3d5d5a8a9fc5065a2fd897464e6ee5320/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f47474747696e6f2f57617265686f757365506174682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GGGGino/WarehousePath/?branch=master)

Get started
===========

[](#get-started)

```
composer require ggggino/warehouse-path

```

#### Initialization from a give matrix

[](#initialization-from-a-give-matrix)

```
use GGGGino\WarehousePath\Warehouse;

public static function getSampleData()
{
    return array(
        array(array('weight' => 2), array('weight' => 1), array('weight' => 100), array('weight' => 1), array('weight' => 2), array('weight' => 1)),
        array(array('weight' => 2), array('weight' => 1), array('weight' => 100), array('weight' => 1), array('weight' => 2), array('weight' => 1)),
        array(array('weight' => 2), array('weight' => 1), array('weight' => 100), array('weight' => 1), array('weight' => 2), array('weight' => 1)),
        array(array('weight' => 2), array('weight' => 2), array('weight' =>   2), array('weight' => 2), array('weight' => 2), array('weight' => 1))
    );
}

/** @var Warehouse $warehouse */
$warehouse = Warehouse::createFromMatrix(self::getSampleData());
```

#### Initialization from a give tree

[](#initialization-from-a-give-tree)

```
use GGGGino\WarehousePath\Warehouse;

$loc1 = new Location('L1');
$loc2 = new Location('L2');
$loc3 = new Location('L3');
$corridor1 = new Location('C1');

$loc1->setBottomRef($loc2);
$loc1->setRightRef($loc3);

$loc3->setBottomRef($loc3);

$arrayPlaces = array($loc1, $loc2, $loc3, $corridor1);

/** @var Warehouse $warehouse */
$warehouse = Warehouse::createFromTree($arrayPlaces);
```

#### Initialization from a json

[](#initialization-from-a-json)

[Look here](resources/simpleWarehouse.json) and [Here](resources/biggerWarehouse.json)for a correct json used to build the warehouse

```
use GGGGino\WarehousePath\Warehouse;

/** @var Warehouse $warehouse */
$warehouse = Warehouse::createFromJson(getcwd() . "/resources/simpleWarehouse.json")
```

#### Initialization in detail

[](#initialization-in-detail)

```
// Instantiate a place collector that contain the type of available places
$placesCollector = new PlacesCollector();

// optionally add the baseplace types (Location, Corridor, Wall)
$placesCollector->addBasePlaceTypes();

// Istantiate the Parser to prepare the places in an array
$wm = new MatrixParser($param, $placesCollector);

// Istantiate a customizable Breadcrumb buider
$breadcrumbBuilder = new BreadthFirstBreadcrumb($placesCollector);

$instance = new Warehouse($placesCollector, $wm, $breadcrumbBuilder);
$instance->setPlaces($wm->parse());
```

### Get distance from a starting point to every other location

[](#get-distance-from-a-starting-point-to-every-other-location)

```
/** @var Place $nodeStart */
$nodeStart = $calculatedArray[4];
$warehouse->getPath($nodeStart);
```

### Get the matrix of proximity

[](#get-the-matrix-of-proximity)

> Call the Warehouse::getPath for every single location passed in the array

```
/** @var Place[] $arrayNodes array of the places to touch */
$arrayNodes = [...]

$matrix = $warehouse->getMultiplePath($arrayNodes);
```

### Best path

[](#best-path)

> Calculate the best path to touch every location from the matrix of proximity

```
/** @var Place[] $arrayNodes array of the places to touch */
$arrayNodes = [...]

$arrayNodeSorted = $warehouse->calculate($arrayNodes, $matrix);
```

With this function you get the best path to follow to touch every location in the warehouse/matrix.

Places
======

[](#places)

Places are the main factor for calculating the best path from a Point A to B.

A warehouse can be seen as a matrix of Place that every item has own weight. From this, the program can create the best path:

**Lx** = Location - Weight 1

**Wx** = Wall - Weight 100

**Cx** = Corridor - Weight 2

L1W1L8L2W2L7L3C1L6L4C2L5Imagine you start from the Place "L1", the best path to "L7" will be:

**L1** -&gt; **L2** -&gt; **L3** -&gt; **C1** -&gt; **L6** -&gt; **L7**

So the distance, adding all the weight in the path, will be:

1 + 1 + 1 + 2 + 1 = **6**

This library starts with these three places:

NameWeightWalkableCorridor2trueLocation1trueWall100falseYou can add as many type of Place as you want.

[Read the complete doc about Places](docs/places.md)

Breadcrumb builder
==================

[](#breadcrumb-builder)

The breadcrumb builder aim to create a matrix from the array of all places. This matrix will be passed to the calculator that calculate the correct order which is the correct path to touch all the places with the less cost possible.

### Breadth First

[](#breadth-first)

With this method I map the wharehouse expanding the area and keep in mind the previous state on every step. In this way I can realize a wharehouse that every place knows the shortest path to specific point

[Read the complete doc about Breadcrumb](docs/breadcrumb_builder.md)

Calculators
===========

[](#calculators)

The calculator is the method that choose the best order to touch every location listed. At the moment only one type of calculation is available.

### Fast calculator

[](#fast-calculator)

In the matrix builded from the distance between every location, I chose for every location the closer location.

[Read the complete doc about Calculators](docs/calculators.md)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

2634d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.0.1PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/71ba17da078527d84402fef98be186df83af523d0896e98907904efea4336b5d?d=identicon)[ggggino](/maintainers/ggggino)

---

Top Contributors

[![GGGGino](https://avatars.githubusercontent.com/u/3227441?v=4)](https://github.com/GGGGino "GGGGino (62 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ggggino-warehouse-path/health.svg)

```
[![Health](https://phpackages.com/badges/ggggino-warehouse-path/health.svg)](https://phpackages.com/packages/ggggino-warehouse-path)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
