webforge / symfony
1.7.1
2017-11-03 12:19 UTC
Requires
- jms/serializer: *
- vlucas/phpdotenv: ^2.2
- webforge/utils: *
- webmozart/json: *
README
为webforge和symfony提供一个连接器,包含常用组件
使用DateTimeHandler
composer require webforge/symfony
将以下内容添加到symfony的config.yml
/services.yml
imports: - { resource: '../../vendor/webforge/symfony/Resources/config/services.yml' }
当您使用webforge/doctrine-compiler与serializer扩展时,您的WebforgeDateTime-Types已经设置好了。否则,使用如下注解
<?php use Doctrine\ORM\Mapping AS ORM; use JMS\Serializer\Annotation AS Serializer; class EntityWithTimestamp { /** * modified timestamp saves the time and date of the last modification * * @var Webforge\Common\DateTime\DateTime * @ORM\Column(type="WebforgeDateTime", nullable=true) * @Serializer\Expose * @Serializer\Type("WebforgeDateTime") */ protected $modified = NULL; public function updateModified() { $this->modified = \Webforge\Common\DateTime\DateTime::now(); } }