grasmash/expander
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
dflydev/dot-access-data | v3.0.2 | 10.25 kB | MIT | prod | |
psr/log | 3.0.0 | 6.77 kB | MIT | prod |
The grasmash/expander is a versatile PHP tool designed for expanding internal property references in PHP arrays files. It uses dot-notated string property references and converts them into corresponding values. This makes it a highly beneficial tool for the real-time expansion of property references in configuration files. Indeed, this feature can greatly simplify the management and utilization of nested arrays in PHP, no matter how complex the data structure may be.
To use the grasmash/expander, you firstly need to include it in your project using composer with the command composer require grasmash/expander
. The package provides the Expander
class which you will use for expanding the property references in the arrays. Property references should be wrapped in ${}
, using dot notation for indicating array keys.
Below is an example code snippet illustrating its usage:
<?php
use Grasmash\Expander\Expander;
$array = [
'type' => 'book',
//...additional array data
'env-test' => '${env.test}',
];
$expander = new Expander();
$expanded = $expander->expandArrayProperties($array);
print_r($expanded);
In the above example, $array
is the array with references to internal properties. The expandArrayProperties
method will expand these references and return the resultant array.
Regarding the documentation for grasmash/expander, detailed information on how to use the package is provided directly in the README file on the package's GitHub page (https://github.com/grasmash/expander). The page offers comprehensive examples which help you understand how to install and use this tool properly, making it an essential resource for learning more about the functionality of grasmash/expander.