PHPackages                             windwalker/registry - 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. [Framework](/categories/framework)
4. /
5. windwalker/registry

Abandoned → [windwalker/structure](/?search=windwalker%2Fstructure)Windwalker-package[Framework](/categories/framework)

windwalker/registry
===================

Windwalker Structure package

3.5.1(7y ago)41163.1k↑12.5%24LGPL-2.0-or-laterPHPPHP &gt;=7.1.3

Since Oct 5Pushed 4y ago3 watchersCompare

[ Source](https://github.com/ventoviro/windwalker-registry)[ Packagist](https://packagist.org/packages/windwalker/registry)[ Docs](https://github.com/ventoviro/windwalker-structure)[ RSS](/packages/windwalker-registry/feed)WikiDiscussions master Synced 1mo ago

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

Windwalker Structure
====================

[](#windwalker-structure)

Windwalker Structure is a storage of nested array or object, help us manage multi-level structures data.

Installation via Composer
-------------------------

[](#installation-via-composer)

Add this to the require block in your `composer.json`.

```
{
    "require": {
        "windwalker/structure": "~3.0"
    }
}
```

Supported Formats
-----------------

[](#supported-formats)

- JSON
- PHP file (return array or class)
- JSON
- [HJSON](https://hjson.org/)
- YAML
- [TOML](https://github.com/toml-lang/toml)
- XML
- INI

Getting Started
---------------

[](#getting-started)

```
use Windwalker\Structure\Structure;

$structure = new Structure;

// Set a value in the structure.
$structure->set('foo', 'bar');

// Get a value from the structure;
$value = $structure->get('foo');
```

Load config by Structure
------------------------

[](#load-config-by-structure)

```
use Windwalker\Structure\Structure;

$structure = new Structure;

// Load by string
$structure->loadString('{"foo" : "bar"}');

$structure->loadString('', 'xml');

// Load by object or array
$structure->load($object);

// Load by file
$structure->loadFile($root . '/config/config.json', 'json');
```

Accessing a Structure by getter &amp; setter
--------------------------------------------

[](#accessing-a-structure-by-getter--setter)

### Get value

[](#get-value)

```
$structure->get('foo');

// Get a non-exists value and return default
$structure->get('foo', 'default');

// OR

$structure->get('foo') ?: 'default';
```

### Set value

[](#set-value)

```
// Set value
$structure->set('bar', $value);

// Sets a default value if not already assigned.
$structure->def('bar', $default);
```

### Accessing children value by path

[](#accessing-children-value-by-path)

```
$json = '{
	"parent" : {
		"child" : "Foo"
	}
}';

$structure = new Structure($json);

$structure->get('parent.child'); // return 'Foo'

$structure->set('parent.child', $value);
```

### Append &amp; Prepend

[](#append--prepend)

Support `push / pop / shift / unshift` methods.

```
$structure->set('foo.bar', array('fisrt', 'second'));

$structure->push('foo.bar', 'third');

$structure->get('foo.bar');
// Result: Array(first, second, third)
```

### Use other separator

[](#use-other-separator)

```
$structure->setSeparator('/');

$data = $structure->get('foo/bar');
```

Accessing a Structure as an Array
---------------------------------

[](#accessing-a-structure-as-an-array)

The `Structure` class implements `ArrayAccess` so the properties of the structure can be accessed as an array. Consider the following examples:

```
// Set a value in the structure.
$structure['foo'] = 'bar';

// Get a value from the structure;
$value = $structure['foo'];

// Check if a key in the structure is set.
if (isset($structure['foo']))
{
	echo 'Say bar.';
}
```

Merge Structure
---------------

[](#merge-structure)

#### Using load\* methods to merge two config files.

[](#using-load-methods-to-merge-two-config-files)

```
$json1 = '{
    "field" : {
        "keyA" : "valueA",
        "keyB" : "valueB"
    }
}';

$json2 = '{
    "field" : {
        "keyB" : "a new valueB"
    }
}';

$structure->loadString($json1);
$structure->loadString($json2);
```

Output

```
Array(
    field => Array(
        keyA => valueA
        keyB => a new valueB
    )
)

```

#### Merge Another Structure

[](#merge-another-structure)

```
$object1 = '{
	"foo" : "foo value",
	"bar" : {
		"bar1" : "bar value 1",
		"bar2" : "bar value 2"
	}
}';

$object2 = '{
	"foo" : "foo value",
	"bar" : {
		"bar2" : "new bar value 2"
	}
}';

$structure1 = new Structure(json_decode($object1));
$structure2 = new Structure(json_decode($object2));

$structure1->merge($structure2);
```

If you just want to merge first level, do not hope recursive:

```
$structure1->merge($structure2, false); // Set param 2 to false that Structure will only merge first level
```

Merge to a child node:

```
$structure->mergeTo('foo.bar', $anotherStructure);
```

Dump to file.
-------------

[](#dump-to-file)

```
$structure->toString();

$structure->toString('xml');

$structure->toString('ini');
```

Dump to one dimension
---------------------

[](#dump-to-one-dimension)

```
$array = array(
    'flower' => array(
        'sunflower' => 'light',
        'sakura' => 'samurai'
    )
);

$structure = new Structure($array);

// Make data to one dimension

$flatted = $structure->flatten();

print_r($flatted);
```

The result:

```
Array
(
    [flower.sunflower] => light
    [flower.sakura] => samurai
)

```

Using YAML
----------

[](#using-yaml)

Add Symfony YAML component in `composer.json`

```
{
	"require-dev": {
		"symfony/yaml": "^4.0||^5.0"
	}
}
```

Using `yaml` format

```
$structure->loadFile($yamlFile, 'yaml');

$structure->loadString('foo: bar', 'yaml');

// Convert to string
$structure->toString('yaml');
```

StructureHelper
---------------

[](#structurehelper)

```
use Windwalker\Structure\StructureHelper;

StructureHelper::loadFaile($file, $format); // File to array
StructureHelper::loadString($string, $format); // String to array
StructureHelper::toString($array, $format); // Array to string

// Use format class
$json = StructureHelper::getFormatClass('json'); // Get JsonFormat
$string = $json::structToString($array);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~28 days

Total

57

Last Release

2660d ago

Major Versions

2.1.9 → 3.0-beta2016-07-03

PHP version history (3 changes)2.0.0-alphaPHP &gt;=5.3.10

3.2PHP &gt;=5.5.9

3.5PHP &gt;=7.1.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1639206?v=4)[Simon Asika](/maintainers/asika32764)[@asika32764](https://github.com/asika32764)

---

Top Contributors

[![asika32764](https://avatars.githubusercontent.com/u/1639206?v=4)](https://github.com/asika32764 "asika32764 (56 commits)")[![megamount](https://avatars.githubusercontent.com/u/17608213?v=4)](https://github.com/megamount "megamount (4 commits)")

---

Tags

phpregistrystoragestructstructureframeworkstructurewindwalker

### Embed Badge

![Health badge](/badges/windwalker-registry/health.svg)

```
[![Health](https://phpackages.com/badges/windwalker-registry/health.svg)](https://phpackages.com/packages/windwalker-registry)
```

###  Alternatives

[windwalker/structure

Windwalker Structure package

434.7M3](/packages/windwalker-structure)[windwalker/renderer

Windwalker Renderer package

864.9M25](/packages/windwalker-renderer)[windwalker/crypt

Windwalker Crypt package

1392.2k6](/packages/windwalker-crypt)

PHPackages © 2026

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