{"id":14984015,"url":"https://github.com/ntidev/datadogauditbundle","last_synced_at":"2025-10-05T11:32:01.023Z","repository":{"id":57029122,"uuid":"176977361","full_name":"ntidev/DataDogAuditBundle","owner":"ntidev","description":"Stores all database changes for doctrine ORM","archived":false,"fork":true,"pushed_at":"2024-09-11T12:51:47.000Z","size":461,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-29T16:22:26.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"DATA-DOG/DataDogAuditBundle","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntidev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-21T15:49:02.000Z","updated_at":"2024-09-11T12:52:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ntidev/DataDogAuditBundle","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2FDataDogAuditBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2FDataDogAuditBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2FDataDogAuditBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2FDataDogAuditBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntidev","download_url":"https://codeload.github.com/ntidev/DataDogAuditBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876996,"owners_count":16554814,"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":[],"created_at":"2024-09-24T14:08:19.525Z","updated_at":"2025-10-05T11:31:55.711Z","avatar_url":"https://github.com/ntidev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Audit bundle\n\nThis bundle creates an audit log for all doctrine ORM database related changes:\n\n- inserts ion changes, association and dissociation actions.\n- if there is an user and updates including their diffs and relation field diffs.\n- many to many relatin token storage, it will link him to the log.\n- the audit entries are inserted within the same transaction during **flush**,\nif something fails the state remains clean.\n\nBasically you can track any change from these log entries if they were\nmanaged through standard **ORM** operations.\n\n**NOTE:** audit cannot track DQL or direct SQL updates or delete statement executions.\n\n## Pre-Install\n\nTo continue using **Query Loggers** methods within the audit log bundle, Symfony versions up to 6.x require the installation of **firehed/dbal-logger v1.0.1**. Make sure to have this installed before proceeding to the next step.\n\n## Install\n\nFirst, install it with composer:\n\n    composer require nti/audit-bundle\n\nThen, add it in your **AppKernel** bundles.\n\n    // app/AppKernel.php\n    public function registerBundles()\n    {\n        $bundles = array(\n            ...\n            new DataDog\\AuditBundle\\DataDogAuditBundle(),\n            ...\n        );\n        ...\n    }\n\nUsing Query:\n\n    //SQL\n    CREATE TABLE audit_logs (id INT AUTO_INCREMENT NOT NULL, source_id INT NOT NULL, target_id INT DEFAULT NULL, blame_id INT DEFAULT NULL, action VARCHAR(12) NOT NULL, tbl VARCHAR(128) NOT NULL, diff LONGTEXT DEFAULT NULL COMMENT'(DC2Type:json_array)', logged_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_D62F2858953C1C61 (source_id), UNIQUE INDEX UNIQ_D62F2858158E0B66 (target_id), UNIQUE INDEX UNIQ_D62F28588C082A2E (blame_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;\n    CREATE TABLE audit_associations (id INT AUTO_INCREMENT NOT NULL, typ VARCHAR(128) NOT NULL, tbl VARCHAR(128) DEFAULT NULL, label VARCHAR(255) DEFAULT NULL, fk VARCHAR(255) NOT NULL, class VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;\n    CREATE TABLE audit_request (id INT AUTO_INCREMENT NOT NULL, method VARCHAR(255) DEFAULT NULL, controller VARCHAR(255) DEFAULT NULL, route VARCHAR(255) DEFAULT NULL, route_params LONGTEXT DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, user_name VARCHAR(255) DEFAULT NULL,portal VARCHAR(255) DEFAULT NULL, query_data LONGTEXT DEFAULT NULL, data LONGTEXT DEFAULT NULL, created_on DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;     ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F2858953C1C61 FOREIGN KEY (source_id) REFERENCES audit_associations (id);\n    ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F2858158E0B66 FOREIGN KEY (target_id) REFERENCES audit_associations (id);\n    ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F28588C082A2E FOREIGN KEY (blame_id) REFERENCES audit_associations(id);\n    ALTER TABLE audit_associations ADD created_on DATETIME NOT NULL;\n\nUsing Doctrine Schema:\n    \n    // Doctrine\n    php bin/console doctrine:schema:update -f\n\n### Config\n\nEnable the audit request in the project:\n\n    // app/config.yml\n    # DataDog\n    data_dog_audit:\n        audit_request:\n            enabled: true\n\nIf you will use a custom database connection use following config:\n\n    // app/config.yml\n    # DataDog\n    data_dog_audit:\n        database:\n            connection_name: nti_logs    \n        audit_request:\n            enabled: true\n\nSee [How to Work with multiple Entity Managers and Connections](https://symfony.com/doc/3.4/doctrine/multiple_entity_managers.html \"https://symfony.com/doc/3.4/doctrine/multiple_entity_managers.html\")\n\n### Annotations\n\nAnnotations has to use in the controller, add Annotations NTIAudit in the class:\n\n    //src/Bundle/Controller/Controller.php\n    use DataDog\\AuditBundle\\Annotations\\NTIAudit;\n\n    /**\n    * Class Controller\n    * @package AppBundle\\Controller\n    * @NTIAudit()\n    * @Route(\"/controller\")\n    */\n    class Controller extends Controller {\n        //TODO CODE HERE\n    }\n\n### Unaudited Entities\n\nSometimes, you might not want to create audit log entries for particular entities.\nYou can achieve this by listing those entities under the `unaudited_entities` configuration\nkey in your `config.yml`, for example:\n\n    data_dog_audit:\n        unaudited_entities:\n            - AppBundle\\Entity\\NoAuditForThis\n\n### Specify Audited Entities \n\nSometimes, it is also possible, that you want to create audit log entries only for particular entities. You can achieve it quite similar to unaudited entities. You can list them under the `audited_entities` configuration key in your `config.yml`, for example:\n\n    data_dog_audit:\n        audited_entities:\n            - AppBundle\\Entity\\AuditForThis\n\nYou can specify either audited or unaudited entities. If both are specified, only audited entities would be taken into account.\n\n### Command\n\nFor delete audit data:\n\n    php bin/console nti:audit:delete {qtyDays}\n\n## License\n\nNTI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntidev%2Fdatadogauditbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntidev%2Fdatadogauditbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntidev%2Fdatadogauditbundle/lists"}