2017 © Pedro Peláez
 

library zf-snap-var-config

Variables in array

image

snapshotpl/zf-snap-var-config

Variables in array

  • Friday, May 18, 2018
  • by snapshotpl
  • Repository
  • 2 Watchers
  • 2 Stars
  • 15,094 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 7 % Grown

The README.md

ZfSnapVarConfig Build Status

Variables in array., (*1)

Additional provides module for Laminas for configurations., (*2)

Usage

Sometimes you want to use same values in other places in your config. What are you doing?, (*3)

<?php
$myIp = '127.0.0.1';
return [
    'db' => $myIp,
    'memcache' => $myIp,
];

Of course it's working, but when you want to share $myIp between separate config files thats challange! ZfSnapVarConfig make a magic here!, (*4)

$data = [
    'ips' => [
        'local' => '127.0.0.1',
        'memcache' => '127.0.0.2',
        'smtp' => '127.0.0.3'
    ],
    'email' => new ZfSnapVarConfig\Value\Env('ADMIN_EMAIL'),
    'db' => ZfSnapVarConfig\Value\Path::fromString('ips/local'),
    'memcache' => ZfSnapVarConfig\Value\Path::fromString('ips|memcache', '|'),
    'email' => [
        'smtp' => ZfSnapVarConfig\Value\Path::fromArray(['ips', 'smtp']),
        'default-mail' => ZfSnapVarConfig\Value\Path::fromString('email'),
        'reply-to' => ZfSnapVarConfig\Value\Path::fromString('email'),
        'other-address' => new ZfSnapVarConfig\Value\Path('ips', 'smtp'),
    ],
];

$service = new ZfSnapVarConfig\VarConfigService();
$replaced = $service->replace($data); // or $service($data);

assertSame([
    'ips' => [
        'local' => '127.0.0.1',
        'memcache' => '127.0.0.2',
        'smtp' => '127.0.0.3'
    ],
    'email' => 'your@email.com',
    'db' => '127.0.0.1',
    'memcache' => '127.0.0.2',
    'email' => [
        'smtp' => '127.0.0.3',
        'default-mail' => 'your@email.com',
        'reply-to' => 'your@email.com',
        'other-address' => '127.0.0.3',
    ],
], $replaced);

On this moment you can use selectors: * ZfSnapVarConfig\Value\Path * ZfSnapVarConfig\Value\Env * ZfSnapVarConfig\Value\Callback, (*5)

You can write your own value manipulator. Just implement ZfSnapVarConfig\Value and create instance in your config., (*6)

How to install?

Via composer.json, (*7)

composer require snapshotpl/zf-snap-var-config

If you want to use this library as Laminas module add ZfSnapVarConfig to your application.config.php file., (*8)

The Versions

18/05 2018

dev-master

9999999-dev

Variables in array

  Sources   Download

The Requires

  • php >=7.0

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

18/05 2018

2.1.0

2.1.0.0

Variables in array

  Sources   Download

The Requires

  • php >=7.0

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

18/05 2018

dev-php72

dev-php72

Variables in array

  Sources   Download

The Requires

  • php >=7.0

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

11/02 2017

2.0.0

2.0.0.0

Variables in array

  Sources   Download

The Requires

  • php >=7.0

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

11/02 2017

dev-php7

dev-php7

Variables in array

  Sources   Download

The Requires

  • php >=7.0

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

11/02 2017

1.2.0

1.2.0.0

Variables in array

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

11/02 2017

dev-separate_service

dev-separate_service

Variables in array

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

configuration zf2 zend framework arrays zend framework 2 zf3 utils zend framework 3

10/02 2017

1.1.1

1.1.1.0

Variables in configuration for Zend Framework 2

  Sources   Download

The Requires

 

The Development Requires

configuration zf2 zend framework zend framework 2

10/02 2017

dev-nested_issue

dev-nested_issue

Variables in configuration for Zend Framework 2

  Sources   Download

The Requires

 

The Development Requires

configuration zf2 zend framework zend framework 2

09/02 2017

1.1.0

1.1.0.0

Variables in configuration for Zend Framework 2

  Sources   Download

The Requires

 

The Development Requires

configuration zf2 zend framework zend framework 2

09/02 2017

dev-bump_php

dev-bump_php

Variables in configuration for Zend Framework 2

  Sources   Download

The Requires

 

The Development Requires

configuration zf2 zend framework zend framework 2

11/12 2015

1.0.0

1.0.0.0

Variables in configuration for Zend Framework 2

  Sources   Download

The Requires

 

The Development Requires

configuration zf2 zend framework zend framework 2