dflydev/dot-access-data
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The dflydev/dot-access-data is a versatile PHP package that allows you to access data in deep data structures using dot notation. This powerful tool simplifies data management by making it easy to retrieve, set, check, and append data in intricate and multi-tiered arrays or structures with minimal effort.
Using dflydev/dot-access-data is straightforward. To begin, you'll need to include the Dflydev\DotAccessData\Data
class in your PHP file using the use
declaration. You can initialize a new Data
object, and then use the set
, get
, append
, has
and remove
methods to manipulate this data structure. Here is an abstract example of dflydev/dot-access-data usage:
use Dflydev\DotAccessData\Data;
$data = new Data;
$data->set('a.b.c', 'C');
$data->set('a.b.d', 'D1');
$data->append('a.b.d', 'D2');
$data->set('a.b.e', ['E0', 'E1', 'E2']);
echo $data->get('a.b.c'); // Outputs 'C'
Also, more concrete example includes:
use Dflydev\DotAccessData\Data;
$data = new Data(['hosts' => [...]]);
$username = $data->get('hosts.hewey.username');
$nick = $data->get('hosts.lewey.nick', 'Unknown');
You can also use Data
as an array since it implements ArrayAccess
interface:
$data['name'] = 'Dewey';
isset($data['name']) === $data->has('name');
As per the readme content on the package's GitHub repository, there is no separate documentation linked or mentioned. However, you can refer to the repository itself for all the necessary details, usage examples and parameters. The code examples in the readme file are quite comprehensive and offer a solid understanding of how to use the package effectively.