PHPackages                             symandy/mapped-resource - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. symandy/mapped-resource

ActiveLibrary[Database &amp; ORM](/categories/database)

symandy/mapped-resource
=======================

Set of reusable resource interfaces and traits mapped by Doctrine attributes

v1.3.1(3y ago)1197MITPHPPHP ^8.0

Since Jan 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Symandy/MappedResource)[ Packagist](https://packagist.org/packages/symandy/mapped-resource)[ RSS](/packages/symandy-mapped-resource/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Symandy Resource Components
===========================

[](#symandy-resource-components)

This package is a set of reusable components and contains interfaces and traits that could be used in any PHP project using Doctrine mapping (attributes). It was mainly designed to be used for [Symfony](https://github.com/symfony/symfony) entities.

This package design was strongly inspired by [Sylius Resource Bundle](https://github.com/Sylius/SyliusResourceBundle)

Installation
------------

[](#installation)

```
$ composer require symandy/mapped-resource
```

Components
----------

[](#components)

The components are stored in `Symandy\Component\Resource\Model` namespace.

Each interface have a corresponding trait and contains one or several attributes :

Name (trait + interface)PropertyMapped columnMethodsResource$ididgetId()Creatable$createdAtcreated\_atgetCreatedAt()
 setCreatedAt(?\\DateTimeInterface)
 create()Updatable$updatedAtupdated\_atgetUpdatedAt()
 setUpdatedAt(?\\DateTimeInterface)
 update()Timestampable
 (extends Creatable &amp; Updatable)---Archivable$archivedAtarchived\_atgetArchivedAt()
 setArchivedAt(?\\DateTimeInterface)
 archive()
 restore()Toggleable$enabledenabledisEnabled()
 setEnabled(bool)
 enable()
 disable()CodeAware$codecodegetCode()
 setCode(?string)SlugAware$slugsluggetSlug()
 setSlug(?string)Versioned$versionversiongetVersion()
 setVersion(?int)Startable$startsAtstarts\_atgetStartsAt()
 setStartsAt(?\\DateTimeInterface)Endable$endsAtends\_atgetEndsAt()
 setEndsAt(?\\DateTimeInterface)PeriodAware
(extends Startable &amp; Endable)--Each trait contains mapping information with attributes. If you are using XML or YAML driver, you have to redefine the mapping for each property (in each entity).

Usage
-----

[](#usage)

### Resource creation

[](#resource-creation)

The best way to use these components is to create a class and an interface for each resource.

It is also possible to create only the class and add the corresponding traits.

#### Example

[](#example)

```
