{"id":15063319,"url":"https://github.com/tuscanicz/doctrine-data-applier","last_synced_at":"2026-02-02T12:48:05.014Z","repository":{"id":57073717,"uuid":"92874667","full_name":"tuscanicz/doctrine-data-applier","owner":"tuscanicz","description":"Symfony bundle for Doctrine Migrations of data using doctrine entities","archived":false,"fork":false,"pushed_at":"2017-05-31T08:37:10.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T04:49:42.630Z","etag":null,"topics":["data","database","doctrine","entity","migrations","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuscanicz.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":"2017-05-30T20:46:42.000Z","updated_at":"2017-05-31T08:05:19.000Z","dependencies_parsed_at":"2022-08-24T14:54:46.696Z","dependency_job_id":null,"html_url":"https://github.com/tuscanicz/doctrine-data-applier","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tuscanicz/doctrine-data-applier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuscanicz%2Fdoctrine-data-applier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuscanicz%2Fdoctrine-data-applier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuscanicz%2Fdoctrine-data-applier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuscanicz%2Fdoctrine-data-applier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuscanicz","download_url":"https://codeload.github.com/tuscanicz/doctrine-data-applier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuscanicz%2Fdoctrine-data-applier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29012682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T10:37:29.253Z","status":"ssl_error","status_checked_at":"2026-02-02T10:37:28.644Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data","database","doctrine","entity","migrations","symfony","symfony-bundle"],"created_at":"2024-09-24T23:54:54.642Z","updated_at":"2026-02-02T12:48:04.997Z","avatar_url":"https://github.com/tuscanicz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doctrine data applier\n\nSymfony bundle for Doctrine Migrations of data using doctrine entities.\nUse this tool to describe your database data by doctrine entities.\nIt requires to modify your entities a bit but for that price,\nyou'll get a mighty tool that will auto-merge entities in your application\nwith those in your database.\n\nThis is very useful when you need to keep your data up-to-date\n in many environments and are necessary for your application to run.\n \nTypical use-case is a user table with your administrator, content manager\n and other \"obligatory\" users or enumerations that are used across your app.\n\nDataApplier will **never affect any data that was not created by DataApplier**\nso your user data can live next to data applier data together in one table.\n\n## How to use\n\nAdd composer dependency: ``composer require tuscanicz/doctrine-data-applier:dev-develop``\n\n### Modify your Entity to be useful with Data Applier\n\nYou need to add some columns to doctrine entity to make them managable by data applier.\n\nIn order to do so you'll have to implement ``DataApplier\\Entity\\DataApplicableEntityInterface``\n that will force you to use ``DataApplier\\Entity\\DataApplicableEntityTrait``\n and present ``id`` column with setter and getter.\n \nThis id must be your primary key in database, see a typical annotation:\n\n```php\n/**\n * @var int\n * @ORM\\Column(type=\"integer\")\n * @ORM\\Id\n * @ORM\\GeneratedValue()\n */\nprivate $id;\n\npublic function getId()\n{\n    return $this-\u003eid;\n}\n\npublic function setId(int $id)\n{\n    $this-\u003eid = $id;\n}\n```\n\nI expect that most of the doctrine entities have such column already defined.\nIf you define your id with different name or consists of complex keys,\n you'll have to fork this repository and fix this limitation :)\n\nNext, you'll have to decide what are the DataApplier identifier columns.\n\nThis tool will decide whether to delete the row, update the data or insert new\n by matching your database contents with entities in your application.\n\nAnnotate them with ``DataApplier\\Annotation\\DataApplierIdentifier``:\n\n```php\n/**\n * @var string\n * @ORM\\Column(type=\"string\")\n * @DataApplierIdentifier()\n */\nprivate $key;\n```\n\nThen create a factory method /or factory class\nthat will set all the necessary attributes to your entity.\nDon't include the primary key in database (``id``),\n these will differ on your environments.\n\nExample:\n```php\npublic static function createNew($value, $key)\n{\n    $self = new self;\n    $self-\u003esetKey($key);\n    $self-\u003esetValue($value);\n\n    return $self;\n}\n```\n\n### Update the database\n\nUse ``doctrine:migrations`` to change the entities.\nGenerating a diff will add a few columns that will help DataApplier to identify a source of data.\n\n### Create a DataApplier for your entity\n\nData applier consists of multiple DataAppliers\n that will implement ``DataApplier\\Data\\DataApplierInterface``.\n \nThe only method ``applyData()`` will return\n an array of entities that you need to keep in your database:\n \n```php\nclass TestDataApplier1 implements DataApplierInterface\n{\n    public function applyData()\n    {\n        return [\n            TestEntity::createNew('value1', 'key1'),\n            TestEntity::createNew('value2', 'key2'),\n            TestEntity::createNew('value3', 'key3'),\n        ];\n    }\n}\n\n```\n\nYou must register ``TestDataApplier1`` as Symfony service\n and add ``doctrine.data_applier`` tag:\n \n```xml\n\u003cservice id=\"your_app.data.test_data_applier1\" class=\"YourApp\\Data\\TestDataApplier1\"\u003e\n    \u003ctag name=\"doctrine.data_applier\"/\u003e\n\u003c/service\u003e\n```\n\n### Register DataApplier bundle\n\n```php\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = [\n            ...,\n            new \\DataApplier\\DataApplierBundle()\n        ];\n    }\n}\n```\n\n### Run DataApplier\n\nIf you managed to go thru all the previous steps - congratulations. :)\n\nYou can now run your data applier via Symfony console:\n``php bin/console data:apply``\n\nThis will update your data in your database.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuscanicz%2Fdoctrine-data-applier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuscanicz%2Fdoctrine-data-applier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuscanicz%2Fdoctrine-data-applier/lists"}