Download the PHP package tourze/doctrine-track-bundle without Composer
On this page you can find all versions of the php package tourze/doctrine-track-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourze/doctrine-track-bundle
More information about tourze/doctrine-track-bundle
Files in tourze/doctrine-track-bundle
Package doctrine-track-bundle
Short Description Doctrine 实体变更跟踪和日志记录 Bundle
License MIT
Informations about the package doctrine-track-bundle
Doctrine Track Bundle
中文
A Symfony bundle for tracking and auditing entity changes with automatic logging of create, update, and delete operations to help maintain data integrity and compliance requirements.
Table of Contents
- Features
- Dependencies
- Required Bundles
- Installation
- Quick Start
- Configuration
- Environment Variables
- Service Configuration
- Advanced Usage
- Custom Entity Requirements
- Understanding Log Data
- Performance Considerations
- Contributing
- License
- Changelog
Features
- Selective Tracking: Only tracks fields explicitly marked with
#[TrackColumn]attribute - Complete Audit Trail: Records entity class, ID, action type, changed data, user, IP, and request ID
- Asynchronous Logging: Non-blocking log persistence for better performance
- Automatic Cleanup: Built-in scheduled cleanup with configurable retention period
- User Context: Automatically captures user information when available
- Request Tracking: Associates changes with request IDs for better debugging
Dependencies
- PHP >= 8.1
- Symfony >= 6.4
- Doctrine ORM >= 3.0
- Doctrine Bundle >= 2.13
Required Bundles
tourze/doctrine-async-insert-bundle: For asynchronous log insertiontourze/request-id-bundle: For request ID trackingtourze/doctrine-user-bundle: For user context trackingtourze/doctrine-ip-bundle: For IP address trackingtourze/doctrine-timestamp-bundle: For timestamp management
Installation
Install via Composer:
If you're not using Symfony Flex, manually register the bundle in config/bundles.php:
Run database migrations to create the tracking table:
Quick Start
-
Mark fields to track with the
#[TrackColumn]attribute: -
Use your entities normally - tracking happens automatically:
- Query tracking logs:
Configuration
Environment Variables
Service Configuration
No additional configuration is required. The bundle automatically:
- Registers Doctrine event listeners
- Configures async logging service
- Sets up cleanup scheduling
Advanced Usage
Custom Entity Requirements
Your entities must have an id property as the primary key for tracking to work:
Understanding Log Data
The tracking logs contain:
objectClass: Full class name of the tracked entityobjectId: Primary key value of the entityaction:create,update, orremovedata: JSON containing field changescreatedBy: User who made the change (if available)createdFromIp: IP address of the requestrequestId: Unique request identifiercreatedAt: Timestamp of the change
Performance Considerations
- Logs are written asynchronously to avoid blocking entity operations
- Only marked fields are tracked, reducing overhead
- Automatic cleanup prevents log table growth
- Consider indexing on
objectClassandobjectIdfor query performance
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure all tests pass (
./vendor/bin/phpunit) - Check code quality (
./vendor/bin/phpstan analyse) - Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
The MIT License (MIT). Please see License File for more information.
Changelog
Please see Releases for version history and upgrade guides.
All versions of doctrine-track-bundle with dependencies
doctrine/dbal Version ^4.0
doctrine/doctrine-bundle Version ^2.13
doctrine/orm Version ^3.0
psr/log Version ^3|^2|^1
symfony/cache Version ^7.3
symfony/cache-contracts Version ^3
symfony/config Version ^7.3
symfony/dependency-injection Version ^7.3
symfony/doctrine-bridge Version ^7.3
symfony/framework-bundle Version ^7.3
symfony/http-foundation Version ^7.3
symfony/http-kernel Version ^7.3
symfony/property-access Version ^7.3
symfony/security-bundle Version ^7.3
symfony/security-core Version ^7.3
symfony/service-contracts Version ^3.6
symfony/yaml Version ^7.3
tourze/bundle-dependency Version 1.*
tourze/doctrine-async-insert-bundle Version 1.0.*
tourze/doctrine-helper Version 1.0.*
tourze/doctrine-indexed-bundle Version 1.0.*
tourze/doctrine-ip-bundle Version 1.1.*
tourze/doctrine-timestamp-bundle Version 1.1.*
tourze/doctrine-user-bundle Version 1.0.*
tourze/request-id-bundle Version 1.0.*
tourze/symfony-dependency-service-loader Version 1.0.*
tourze/symfony-schedule-entity-clean-bundle Version 1.1.*