{"id":13617206,"url":"https://github.com/KnpLabs/DoctrineBehaviors","last_synced_at":"2025-04-14T03:33:13.832Z","repository":{"id":2679686,"uuid":"3671952","full_name":"KnpLabs/DoctrineBehaviors","owner":"KnpLabs","description":"Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior","archived":false,"fork":false,"pushed_at":"2024-06-11T18:17:31.000Z","size":1203,"stargazers_count":914,"open_issues_count":63,"forks_count":290,"subscribers_count":49,"default_branch":"master","last_synced_at":"2024-09-06T22:12:07.830Z","etag":null,"topics":["behavior","doctrine","doctrine2","orm","php","trait"],"latest_commit_sha":null,"homepage":"http://knplabs.com","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/KnpLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-03-09T15:36:10.000Z","updated_at":"2024-09-02T11:58:43.000Z","dependencies_parsed_at":"2024-01-16T15:41:49.039Z","dependency_job_id":"89e3f85e-241c-416c-956d-b069d2592985","html_url":"https://github.com/KnpLabs/DoctrineBehaviors","commit_stats":{"total_commits":685,"total_committers":133,"mean_commits":5.150375939849624,"dds":0.7474452554744526,"last_synced_commit":"aa7c160caec5716d4b9e065e4ed4a90a1cef9c50"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnpLabs%2FDoctrineBehaviors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnpLabs%2FDoctrineBehaviors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnpLabs%2FDoctrineBehaviors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnpLabs%2FDoctrineBehaviors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KnpLabs","download_url":"https://codeload.github.com/KnpLabs/DoctrineBehaviors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248815782,"owners_count":21165981,"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":["behavior","doctrine","doctrine2","orm","php","trait"],"created_at":"2024-08-01T20:01:38.325Z","updated_at":"2025-04-14T03:33:08.819Z","avatar_url":"https://github.com/KnpLabs.png","language":"PHP","funding_links":[],"categories":["PHP","Related Projects"],"sub_categories":[],"readme":"# Doctrine Behaviors\n\n[![Downloads](https://img.shields.io/packagist/dt/knplabs/doctrine-behaviors.svg?style=flat-square)](https://packagist.org/packages/knplabs/doctrine-behaviors)\n\nThis PHP library is a collection of traits and interfaces that add behaviors to Doctrine entities and repositories.\n\nIt currently handles:\n\n * [Blameable](/docs/blameable.md)\n * [Loggable](/docs/loggable.md)\n * [Sluggable](/docs/sluggable.md)\n * [SoftDeletable](/docs/soft-deletable.md)\n * [Uuidable](/docs/uuidable.md)\n * [Timestampable](/docs/timestampable.md)\n * [Translatable](/docs/translatable.md)\n * [Tree](/docs/tree.md)\n\n## Install\n\n```bash\ncomposer require knplabs/doctrine-behaviors\n```\n\n## Usage\n\nAll you have to do is to define a Doctrine entity:\n\n- implemented interface\n- add a trait\n\nFor some behaviors like tree, you can use repository traits:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Repository;\n\nuse Doctrine\\ORM\\EntityRepository;\nuse Knp\\DoctrineBehaviors\\ORM\\Tree\\TreeTrait;\n\nfinal class CategoryRepository extends EntityRepository\n{\n    use TreeTrait;\n}\n```\n\nVoilà!\n\nYou now have a working `Category` that behaves like.\n\n## PHPStan\n\nA PHPStan extension is available and provides the following features:\n  - Provides correct return type for `TranslatableInterface::getTranslations()` and `TranslatableInterface::getNewTranslations()`\n  - Provides correct return type for `TranslatableInterface::translate()`\n  - Provides correct return type for `TranslationInterface::getTranslatable()`\n\nInclude `phpstan-extension.neon` in your project's PHPStan config:\n```yaml\n# phpstan.neon\nincludes:\n    - vendor/knplabs/doctrine-behaviors/phpstan-extension.neon\n```\n\n## 3 Steps to Contribute\n\n- **1 feature per pull-request**\n- **New feature needs tests**\n- Tests and static analysis **must pass**:\n\n    ```bash\n    vendor/bin/phpunit\n    composer fix-cs\n    composer phpstan\n    ```\n\n## Upgrade 1.x to 2\n\nThere have been many changes between 1 and 2, but don't worry.\nThis package uses [Rector](https://github.com/rectorphp/rector), that handles upgrade for you.\n\n```bash\ncomposer require rector/rector --dev\n```\n\nCreate `rector.php` config:\n\n```bash\nvendor/bin/rector init\n```\n\nAdd Doctrine Behaviors upgrade set to `rector.php`:\n\n```php\nuse Rector\\Core\\Configuration\\Option;\nuse Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ContainerConfigurator;\nuse Rector\\Doctrine\\Set\\DoctrineSetList;\n\nreturn static function (ContainerConfigurator $containerConfigurator): void {\n    $containerConfigurator-\u003eimport(DoctrineSetList::DOCTRINE_BEHAVIORS_20);\n};\n```\n\nRun Rector:\n\n```bash\nvendor/bin/rector process src\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnpLabs%2FDoctrineBehaviors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKnpLabs%2FDoctrineBehaviors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnpLabs%2FDoctrineBehaviors/lists"}