{"id":19345248,"url":"https://github.com/symandy/resource","last_synced_at":"2025-04-23T04:36:29.166Z","repository":{"id":43293005,"uuid":"401398909","full_name":"Symandy/Resource","owner":"Symandy","description":"Set of reusable resource interfaces and traits ","archived":false,"fork":false,"pushed_at":"2022-11-24T15:00:24.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T12:12:54.148Z","etag":null,"topics":["php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Symandy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-30T15:45:08.000Z","updated_at":"2024-01-16T16:05:54.000Z","dependencies_parsed_at":"2023-01-21T15:17:02.606Z","dependency_job_id":null,"html_url":"https://github.com/Symandy/Resource","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Symandy%2FResource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Symandy%2FResource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Symandy%2FResource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Symandy%2FResource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Symandy","download_url":"https://codeload.github.com/Symandy/Resource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372465,"owners_count":21419719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","symfony"],"created_at":"2024-11-10T04:05:53.394Z","updated_at":"2025-04-23T04:36:28.805Z","avatar_url":"https://github.com/Symandy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symandy Resource Components\n\nThis package is a set of reusable components and contains interfaces and traits that could be used in any PHP project. \nIt was mainly designed to be used for [Symfony](https://github.com/symfony/symfony) entities.\n\nThis package design was strongly inspired by [Sylius Resource Bundle](https://github.com/Sylius/SyliusResourceBundle)\n\n\n## Installation\n\n```shell\n$ composer require symandy/resource\n```\n\n\n## Components\nThe components are stored in `Symandy\\Component\\Resource\\Model` namespace.\n\nEach interface have a corresponding trait and contains one or several attributes :\n\n| Name (trait + interface)                           | Property    | Methods                                                                                |\n|----------------------------------------------------|-------------|----------------------------------------------------------------------------------------|\n| Resource                                           | $id         | getId()                                                                                |\n| Creatable                                          | $createdAt  | getCreatedAt() \u003cbr/\u003e setCreatedAt(?\\DateTimeInterface)\u003cbr/\u003e create()                   |\n| Updatable                                          | $updatedAt  | getUpdatedAt() \u003cbr/\u003e setUpdatedAt(?\\DateTimeInterface)\u003cbr/\u003e update()                   |\n| Timestampable\u003cbr/\u003e (extends Creatable \u0026 Updatable) | -           | -                                                                                      |\n| Archivable                                         | $archivedAt | getArchivedAt() \u003cbr/\u003e setArchivedAt(?\\DateTimeInterface)\u003cbr/\u003e archive()\u003cbr/\u003e restore() |\n| Toggleable                                         | $enabled    | isEnabled() \u003cbr/\u003e setEnabled(bool)\u003cbr/\u003e enable()\u003cbr/\u003e disable()                        |\n| CodeAware                                          | $code       | getCode() \u003cbr/\u003e setCode(?string)                                                       |\n| SlugAware                                          | $slug       | getSlug() \u003cbr/\u003e setSlug(?string)                                                       |\n| Versioned                                          | $version    | getVersion() \u003cbr/\u003e setVersion(?int)                                                    |\n| Startable                                          | $startsAt   | getStartsAt() \u003cbr/\u003e setStartsAt(?\\DateTimeInterface)                                   |\n| Endable                                            | $endsAt     | getEndsAt() \u003cbr/\u003e setEndsAt(?\\DateTimeInterface)                                       |\n| PeriodAware\u003cbr/\u003e(extends Startable \u0026 Endable)      | -           | -                                                                                      |\n\n\n## Usage\n\n### Resource creation\n\nThe best way to use these components is to create a class and an interface for each resource.\n\nIt is also possible to create only the class and add the corresponding traits.\n\n#### Example  \n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Symandy\\Component\\Resource\\Model\\ResourceInterface;\nuse Symandy\\Component\\Resource\\Model\\TimestampableInterface;\nuse Symandy\\Component\\Resource\\Model\\ToggleableInterface;\n\ninterface PostInterface extends ResourceInterface, ToggleableInterface, TimestampableInterface\n{\n    # Other methods\n}\n\n```\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Symandy\\Component\\Resource\\Model\\ResourceTrait;\nuse Symandy\\Component\\Resource\\Model\\TimestampableTrait;\nuse Symandy\\Component\\Resource\\Model\\ToggleableTrait;\n\nclass Post implements PostInterface\n{\n    use ResourceTrait, ToggleableTrait, TimestampableTrait;\n\n    # Other attributes with getters / setters\n}\n\n```\n\n### Use the resource in your app\n\n\n```php\n\u003c?php\nuse App\\Post;\n\n# ...\n$post = new Post();\n\n$id = $post-\u003egetId();\n$post-\u003eenable();\n$post-\u003ecreate();\n# ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymandy%2Fresource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymandy%2Fresource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymandy%2Fresource/lists"}