bengor-file/doctrine-orm-bridge
Doctrine ORM bridge for BenGorFile/File. Provides adapters/mappings to persist File domain objects with Doctrine ORM in PHP (>=5.5). Install via Composer; fully tested with PHPSpec. Documentation lives in the main File library docs.
doctrine/orm or illuminate/database bridges. This package does not natively support Eloquent, requiring additional abstraction if Laravel’s ORM is the primary choice.BenGorFile entities into Doctrine-compatible types (e.g., File → Entity). This is clean but assumes tight coupling to BenGorFile’s API.File entities to Doctrine entities with fields like id, name, path, size, and metadata.FileList) and basic CRUD via Doctrine’s EntityManager.spatie/laravel-medialibrary (Eloquent-based).voku/doctrine-file-embeddable (Doctrine-focused).BenGorFile support S3/local storage? If not, how will this scale?BenGorFile usage (non-Doctrine) transition to ORM?spatie/laravel-medialibrary or similar been ruled out?doctrine/orm and configuring it alongside Eloquent.illuminate/database to share connections or create a dual-ORM setup.// config/doctrine.php
return [
'driver' => 'orm',
'entity_managers' => [
'default' => [
'connection' => 'mysql', // Shared with Laravel
'mappings' => [
'BenGorFile' => [
'type' => 'annotation',
'namespace' => 'BenGorFile',
'path' => 'vendor/bengor-file/file/src',
],
],
],
],
];
composer require bengor-file/file).BenGorFile docs.BenGorFile usages (e.g., file uploads, metadata storage).UserUpload, Document).BenGorFile for storage logic.
// Doctrine Entity
#[ORM\Entity]
class UserDocument {
#[ORM\Embedded(class: 'BenGorFile\File')]
private File $file;
}
BenGorFile entities (e.g., File, FileList).// src/DoctrineMigrations/Version20230101000000.php
public function up(): void {
$this->addSql('CREATE TABLE file (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
path VARCHAR(255),
size INT,
mime_type VARCHAR(100)
)');
}
EntityManager in Laravel’s container:
// config/app.php
'providers' => [
Doctrine\ORM\Bridge\DoctrineServiceProvider::class,
],
class FileRepository {
public function __construct(private EntityManager $em) {}
public function save(File $file): void {
$this->em->persist($file);
$this->em->flush();
}
}
BenGorFile v0.4+. Older versions may break.File entity persistence.BenGorFile usages with Doctrine entities.File::save() to EntityManager::persist().BenGorFile calls in favor of Doctrine repositories.count() → length() changes).BenGorFile and Doctrine ORM may have conflicting dependencies.composer.json.spatie/laravel-medialibrary).How can I help you explore Laravel packages today?