承接 rossriley/doctrine-entity-base 相关项目开发

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

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

rossriley/doctrine-entity-base

Composer 安装命令:

composer require rossriley/doctrine-entity-base

包简介

Single class package to provide base getter/setter functions for Doctrine Entities

README 文档

README

This base class is designed to provide a few out of the box hooks for Entity classes.

Extending

Create your entity class and simply extend this base class. For example:

<?php

namespace Myproject;

use Doctrine\Entity\Base;

class Myentity extends Base
{
    protected $option1;
    protected $option2;
    
}

?>

Constructing with data

You can now create a new entity class and pre-seed it with data.

$object = new Myentity(['option1'=>'test','option2'=>'test']);

Property getters and setters

You can get and set properties via getter and setter syntax.

$object = new Myentity();
$object->option1 = 'test';
echo $object->option1; // 'test'

Support for method getters and setters

If you'd prefer to use methods to get and set, this works the same:

$object = new Myentity();
$object->setOption1('test');
echo $object->getOption1(); // 'test'

Serialize

You can quickly serialize your entity object by calling the serialize() method.

$object = new Myentity();
$object->setOption1('test');
print_r($object->serialize()); // ['option1'=>'test', 'option2'=>'']

Providing your own methods.

If you want to override the default behaviour for any of the properties on your object then you can do so by supplying your own methods. These will always be used ahead of the fallback behaviour.

<?php

namespace Myproject;

use Doctrine\Entity\Base;

class Myentity extends Base
{
    protected $option1;
    protected $option2;
    
    
    public function setOption1($val)
    {
        $this->option1 = json_encode($val);
    }
    
    public function getOption1()
    {
        return json_decode($val);
    }
    
    public function serializeOption1()
    {
        return json_decode($val);
    }
    
}

?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固