2017 © Pedro Peláez
 

windwalker-package structure

Windwalker Structure package

image

windwalker/structure

Windwalker Structure package

  • Sunday, July 8, 2018
  • by asika32764
  • Repository
  • 3 Watchers
  • 14 Stars
  • 350,168 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 52 Versions
  • 20 % Grown

The README.md

Windwalker Structure

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

Installation via Composer

Add this to the require block in your composer.json., (*2)

``` json { "require": { "windwalker/structure": "~3.0" } }, (*3)


## 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 ``` php 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

``` php use Windwalker\Structure\Structure;, (*4)

$structure = new Structure;, (*5)

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

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

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

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


## Accessing a Structure by getter & setter ### Get value ``` php $structure->get('foo'); // Get a non-exists value and return default $structure->get('foo', 'default'); // OR $structure->get('foo') ?: 'default';

Set value

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

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


### Accessing children value by path ``` php $json = '{ "parent" : { "child" : "Foo" } }'; $structure = new Structure($json); $structure->get('parent.child'); // return 'Foo' $structure->set('parent.child', $value);

Append & Prepend

Support push / pop / shift / unshift methods., (*12)

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

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

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


### Use other separator ``` php $structure->setSeparator('/'); $data = $structure->get('foo/bar');

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:, (*16)

``` php // Set a value in the structure. $structure['foo'] = 'bar';, (*17)

// Get a value from the structure; $value = $structure['foo'];, (*18)

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


## Merge Structure #### Using load* methods to merge two config files. ``` php $json1 = '{ "field" : { "keyA" : "valueA", "keyB" : "valueB" } }'; $json2 = '{ "field" : { "keyB" : "a new valueB" } }'; $structure->loadString($json1); $structure->loadString($json2);

Output, (*20)

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

Merge Another Structure

``` php $object1 = '{ "foo" : "foo value", "bar" : { "bar1" : "bar value 1", "bar2" : "bar value 2" } }';, (*21)

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

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

$structure1->merge($structure2);, (*24)


If you just want to merge first level, do not hope recursive: ``` php $structure1->merge($structure2, false); // Set param 2 to false that Structure will only merge first level

Merge to a child node:, (*25)

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


## Dump to file. ``` php $structure->toString(); $structure->toString('xml'); $structure->toString('ini');

Dump to one dimension

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

$structure = new Structure($array);, (*28)

// Make data to one dimension, (*29)

$flatted = $structure->flatten();, (*30)

print_r($flatted);, (*31)


The result:

Array ( [flower.sunflower] => light [flower.sakura] => samurai ), (*32)


## Using YAML Add Symfony YAML component in `composer.json` ``` json { "require-dev": { "symfony/yaml": "^4.0||^5.0" } }

Using yaml format, (*33)

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

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

// Convert to string $structure->toString('yaml');, (*36)


## StructureHelper ``` php 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);

The Versions

08/07 2018

dev-master

9999999-dev https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

08/07 2018

3.4.3

3.4.3.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

08/07 2018

3.4.4

3.4.4.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

15/06 2018

3.4.1

3.4.1.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

15/06 2018

3.4.2

3.4.2.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

10/06 2018

3.4

3.4.0.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

20/02 2018

dev-test

dev-test https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

20/02 2018

3.3

3.3.0.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

20/02 2018

3.3.1

3.3.1.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

20/02 2018

3.3.2

3.3.2.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

25/06 2017

3.2.4

3.2.4.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

25/06 2017

3.2.5

3.2.5.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

25/06 2017

3.2.6

3.2.6.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

25/06 2017

3.2.7

3.2.7.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

25/06 2017

3.2.8

3.2.8.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

09/06 2017

3.2.2

3.2.2.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

09/06 2017

3.2.3

3.2.3.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

05/06 2017

3.2.1

3.2.1.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

05/06 2017

3.2

3.2.0.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework structure windwalker

21/03 2017

3.1.4

3.1.4.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

21/03 2017

3.1.5

3.1.5.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

21/03 2017

3.1.6

3.1.6.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

19/11 2016

3.1.3

3.1.3.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

11/10 2016

3.1

3.1.0.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

11/10 2016

3.1.1

3.1.1.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

11/10 2016

3.1.2

3.1.2.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

07/10 2016

3.0.1

3.0.1.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

18/07 2016

3.0

3.0.0.0 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

06/07 2016

3.0-beta2

3.0.0.0-beta2 https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

04/07 2016

3.0-beta

3.0.0.0-beta https://github.com/ventoviro/windwalker-structure

Windwalker Structure package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework structure windwalker

07/03 2016

2.1.7

2.1.7.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

07/03 2016

2.1.8

2.1.8.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

07/03 2016

2.1.9

2.1.9.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

12/02 2016

2.1.6

2.1.6.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

07/09 2015

2.1.2

2.1.2.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

07/09 2015

2.1.4

2.1.4.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

07/09 2015

2.1.5

2.1.5.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

21/08 2015

2.1.1

2.1.1.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

11/08 2015

2.1

2.1.0.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

27/07 2015

2.0.9

2.0.9.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

13/03 2015

2.0.7

2.0.7.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

13/03 2015

2.0.8

2.0.8.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.0

2.0.0.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.1

2.0.1.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.2

2.0.2.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.3

2.0.3.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.4

2.0.4.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.5

2.0.5.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

16/12 2014

2.0.6

2.0.6.0 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

24/11 2014

2.0.0-beta2

2.0.0.0-beta2 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

05/10 2014

2.0.0-beta1

2.0.0.0-beta1 https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker

05/10 2014

2.0.0-alpha

2.0.0.0-alpha https://github.com/ventoviro/windwalker-registry

Windwalker Registry package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework registry windwalker