PHPackages                             symandy/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. symandy/resource

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

symandy/resource
================

Set of reusable resource interfaces and traits

v1.3.1(3y ago)214.3k↓50%MITPHPPHP &gt;=7.4

Since Aug 31Pushed 3y ago1 watchersCompare

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

READMEChangelog (6)Dependencies (1)Versions (7)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. 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/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)PropertyMethodsResource$idgetId()Creatable$createdAtgetCreatedAt()
 setCreatedAt(?\\DateTimeInterface)
 create()Updatable$updatedAtgetUpdatedAt()
 setUpdatedAt(?\\DateTimeInterface)
 update()Timestampable
 (extends Creatable &amp; Updatable)--Archivable$archivedAtgetArchivedAt()
 setArchivedAt(?\\DateTimeInterface)
 archive()
 restore()Toggleable$enabledisEnabled()
 setEnabled(bool)
 enable()
 disable()CodeAware$codegetCode()
 setCode(?string)SlugAware$sluggetSlug()
 setSlug(?string)Versioned$versiongetVersion()
 setVersion(?int)Startable$startsAtgetStartsAt()
 setStartsAt(?\\DateTimeInterface)Endable$endsAtgetEndsAt()
 setEndsAt(?\\DateTimeInterface)PeriodAware
(extends Startable &amp; Endable)--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)

```
