承接 kevbradwick/drift 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kevbradwick/drift

Composer 安装命令:

composer require kevbradwick/drift

包简介

A lightweight PHP library for mapping data to PHP classes

README 文档

README

Build Status

Drift is a PHP library for mapping arbitrary data to PHP classes.

Installation

Drift is available on Packagist, so you can use composer;

composer require kevbradwick/drift

Usage

Say you have a class with private member variables like this;

namespace Application;

class Actor
{
    /**
     * @Drift\String()
     */
    private $name;
    
    /**
     * @Drift\Int()
     */
    private $age;
    
    /**
     * @Drift\Date(field="date_of_birth")
     */
    private $dateOfBirth;
}

And you have some data, possibly consumed from an API, that looks like this;

$data = [
    'name' => 'Arnold Schwarzenegger',
    'age' => 68,
    'date_of_birth' => 'July 30, 1947'
]

You can then use Drift\Mapper to create a new instance of the class, initialised with the data.

use Drift\Mapper;
use Drift\Reader\AnnotationReader;
use Application\Actor;

$mapper = new Mapper(new AnnotationReader());
$mapper->setData($data);

$actor = $mapper->instantiate(Actor::class);

In addition to annotations, you can specify mapping using Yaml or plain old php.

Full documentation can be found on the Wiki.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固