Download the PHP package team-mate-pro/doctrine-utils-bundle without Composer
On this page you can find all versions of the php package team-mate-pro/doctrine-utils-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download team-mate-pro/doctrine-utils-bundle
More information about team-mate-pro/doctrine-utils-bundle
Files in team-mate-pro/doctrine-utils-bundle
Package doctrine-utils-bundle
Short Description Doctrine utilities bundle for Team Mate Pro - handles file persistence and other Doctrine enhancements
License MIT
Informations about the package doctrine-utils-bundle
Team Mate Pro Doctrine Utils Bundle
A Symfony bundle providing Doctrine utilities for file persistence with Flysystem storage backends.
Features
- Automatic file upload to Flysystem storage on entity persist
- Automatic file deletion from storage on entity removal
- Automatic entity timestamping (createdAt/updatedAt)
- Configurable storage backends (local, S3, Azure, etc.)
- Enable/disable functionality via configuration
- Factory pattern for flexible entity integration
- Reusable entity traits (AutoIncrementIdTrait, UuidIdTrait)
Requirements
- PHP 8.3+
- Symfony 7.0+
- Doctrine ORM 3.0+
- League Flysystem 3.0+
Installation
Register the Bundle
If you're not using Symfony Flex, add the bundle to config/bundles.php:
Configuration
Create config/packages/team_mate_pro_doctrine_utils.yaml:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enable_file_persistence |
boolean | false |
Enable/disable the file persistence listener |
storage_service |
string | 'defaultStorage' |
Flysystem storage service ID |
enable_timestamp_listener |
boolean | false |
Enable/disable the timestamp listener |
Setup
1. Use the Built-in File Entity (Recommended)
The bundle provides a ready-to-use File entity with UUID-based IDs:
The built-in File entity:
- Uses
UuidIdTraitfor UUID-based primary keys - Implements
FileInterfacefromteam-mate-pro/contracts - Includes
isWebImage()helper method - Supports optional
fileUrlfor public URLs (S3, CDN, etc.) - Provides
File::createFromUploadedFile(UploadedFile $file)for Symfony file uploads - Provides
File::createFromInterface(FileInterface $file)for copying from other implementations
Register Doctrine Mapping for the Built-in Entity
To use the built-in File entity, you need to register its mapping in your Doctrine configuration.
Add to config/packages/doctrine.yaml:
Then generate and run the migration:
The migration will create the files table with the following structure:
| Column | Type | Description |
|---|---|---|
id |
uuid (binary) | Primary key (UUID v4) |
name |
varchar(255) | Original filename |
mime |
varchar(100) | MIME type |
bytes |
integer | File size in bytes |
real_path |
varchar(500) | Path to the file on disk |
created_at |
datetime_immutable | Creation timestamp |
file_url |
varchar(500), nullable | Public URL (CDN, S3, etc.) |
2. Custom File Entity (Optional)
If you need a custom entity, implement TeamMatePro\Contracts\Model\FileInterface:
Then create a custom factory implementing EntityFileFactoryInterface:
Register your custom factory in config/services.yaml:
3. Configure Flysystem Storage
Using league/flysystem-bundle:
Or define your own Flysystem service:
Usage
Once configured, the bundle automatically handles file persistence:
Disabling File Persistence
To disable the listener without removing the bundle:
When disabled, the service is completely removed from the container (zero overhead).
Using Different Storage Backends
AWS S3
Azure Blob Storage
Testing
Timestamp Listener
The bundle provides automatic timestamping for entities implementing TimeStampAbleInterface.
Setup
-
Enable the listener in configuration:
- Implement
TimeStampAbleInterfaceon your entity:
The listener automatically calls timestamp() on:
prePersist- When entity is first persistedpreUpdate- When entity is updated
Entity Traits
AutoIncrementIdTrait
Provides auto-incrementing integer ID functionality for Doctrine entities.
The trait provides:
protected ?int $id- Auto-incrementing primary keygetId(): string- Returns the ID as string (or'N/A'if not yet persisted)
UuidIdTrait
Provides UUID-based ID functionality for Doctrine entities using Symfony UID component.
The trait provides:
protected Uuid $id- UUID primary key (requires manual initialization in constructor)getId(): string- Returns the UUID as string
Helper Functions
The bundle provides utility functions for UUID binary conversion:
Usage in Doctrine Queries
Troubleshooting
Verify Factory Registration
Check Listener Registration
Clear Cache
License
See LICENSE file.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
All versions of doctrine-utils-bundle with dependencies
ext-fileinfo Version *
symfony/framework-bundle Version ^7.0
symfony/dependency-injection Version ^7.0
symfony/config Version ^7.0
symfony/http-foundation Version ^7.0
doctrine/orm Version ^3.0
doctrine/doctrine-bundle Version ^2.0
symfony/uid Version ^7.0
symfony/doctrine-bridge Version ^7.0
league/flysystem Version ^3.0
team-mate-pro/contracts Version ^1.0.11