kyserbyte/ypd 问题修复 & 功能扩展

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

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

kyserbyte/ypd

Composer 安装命令:

composer require kyserbyte/ypd

包简介

Ypd Php Decorator implements "decorators/annotations and meta-programming" in PHP, via doc comments.

README 文档

README

Ypd Php Decorator implements "decorators/annotations and meta-programming" in PHP, via doc comments.

INSTALL

You can install the package with composer: composer require kyserbyte/ypd

USAGE

At the monent is implemented only the ypd::jsonSerialize decorator. To activate the decorator you have to implement the JsonSerializable interface in the class that you want to make json serializable via the decorator. Then you have to add the YPDJsonSerializer trait to your class. This trait has an internal implementation of the method jsonSerialize() required by the JsonSerializable interface, so you need only to declare the implements statement in you class. Now you are able to use the decorator inside a doc comment, in order to declare what properties you want to expose to json. The decorator works for now only with the public properties of a class.

jsonSerialize decorator

Inside a doc comment over your property, you need to declare the decorator with the syntax

/**
* ypd::jsonSerialize(name=XX,if=YY) 
*/
public $propName;

with the declaration you can pass 2 arguments to the decorator.

  • name: specify a custom name for the property when exported to json
  • if: a Function that resolve to boolean. You can use it to implement a conditional logic for export the property. The Function must be declared in the same class of the property or in a trait used by the class and must be public.

Take a look to DemoJsonSerialize class for more info about usage.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固