woutvw/nested-object 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

woutvw/nested-object

最新稳定版本:v1.0.0

Composer 安装命令:

composer require woutvw/nested-object

包简介

A PHP class that allows creating nested objects with the flexibility of JSON but the advantages of PHP classes.

README 文档

README

Latest Stable Version Total Downloads License

A PHP class that allows you to create nested objects with the flexibility of JSON objects, but with the advantages of PHP classes.

Installation

Install the package via Composer:

composer require woutvw/nested-object

Usage

This class allows you to dynamically create nested objects without predefined structures, similar to working with JSON in JavaScript, but maintaining the advantages of PHP.

Creating a Nested Object

You can create an object with nested properties like this:

use WoutVW\NestedObject;

// Initialize with data
$data = [
    'user' => [
        'name' => 'John Doe',
        'email' => 'john@example.com'
    ],
    'status' => 'active'
];

$object = new NestedObject($data);

// Access nested properties
echo $object->user->name; // Outputs 'John Doe'

// Set new properties
$object->user->age = 30;

Setting values

You can assign new values just like a regular object:

$object->user->city = 'New York';

Converting to an Array

You can convert the nested object back to an array using the toArray() method:

$array = $object->toArray();
print_r($array);

License

MIT

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-26