PHPackages                             martin3r/platform-media - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. martin3r/platform-media

ActiveLibrary[Image &amp; Media](/categories/media)

martin3r/platform-media
=======================

Media Service for Platform

098PHP

Since Mar 7Pushed 2mo agoCompare

[ Source](https://github.com/martin3r-me/platforms-media)[ Packagist](https://packagist.org/packages/martin3r/platform-media)[ RSS](/packages/martin3r-platform-media/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Media Service
=============

[](#media-service)

Ein zentraler Media Service für die Platform mit Upload, Verwaltung und Wiederverwendung von Dateien über verschiedene Module hinweg.

🚀 Installation &amp; Setup
--------------------------

[](#-installation--setup)

### 1. Service Provider registrieren

[](#1-service-provider-registrieren)

Füge den Media Service Provider in der Zielanwendung hinzu:

```
// config/app.php
'providers' => [
    // ...
    Platform\Media\MediaServiceProvider::class,
],
```

### 2. Config publishen

[](#2-config-publishen)

```
php artisan vendor:publish --tag=media-config
```

### 3. .env Konfiguration

[](#3-env-konfiguration)

```
# Media Service Configuration
MEDIA_DISK=wasabi
MEDIA_MAX_SIZE=52428800
MEDIA_CHUNK_SIZE=1048576
MEDIA_CONCURRENT_UPLOADS=3
MEDIA_PER_PAGE=20
MEDIA_POOL_PER_PAGE=50

# Storage Configuration (bereits vorhanden)
FILESYSTEMS_DISK=wasabi
WASABI_ACCESS_KEY_ID=your_key
WASABI_SECRET_ACCESS_KEY=your_secret
WASABI_DEFAULT_REGION=eu-central-1
WASABI_BUCKET=your_bucket
WASABI_URL=https://s3.eu-central-1.wasabisys.com
```

### 4. Migrations ausführen

[](#4-migrations-ausführen)

```
php artisan migrate
```

### 5. Seeder ausführen

[](#5-seeder-ausführen)

```
php artisan db:seed --class=Platform\\Media\\Database\\Seeders\\MediaMimeTypeSeeder
```

📋 Features
----------

[](#-features)

### Zentrale Media Pool + Kontextuelle Duplikation

[](#zentrale-media-pool--kontextuelle-duplikation)

Der Media Service implementiert ein intelligentes System für die Dateiverwaltung:

#### Konzept

[](#konzept)

- **Media Pool**: Zentrale Dateiverwaltung für wiederverwendbare Medien
- **Kontextuelle Duplikation**: Dateien werden in kontextspezifische Pfade dupliziert
- **Unabhängige Verwaltung**: Jeder Kontext kann seine Dateien unabhängig löschen

#### Workflow

[](#workflow)

1. **Upload in Pool**: Datei wird zentral hochgeladen
2. **Verwendung in Kontext**: Datei wird in kontextspezifischen Pfad dupliziert
3. **Unabhängige Löschung**: Kontext-Dateien können gelöscht werden ohne Pool zu beeinflussen

#### S3-Struktur

[](#s3-struktur)

```
bucket/
├── {env}/media-pool/shared/          # Zentrale Dateien
│   ├── 2025/01/
│   └── 2025/02/
├── {env}/internal/                   # Kontext-Dateien
│   ├── hcm/123/2025/01/
│   ├── food-service/456/2025/01/
│   └── okr/789/2025/01/
├── {env}/public/                     # Öffentliche Dateien
└── {env}/private/                    # Private Dateien

```

#### Datenbank-Beispiel

[](#datenbank-beispiel)

```
-- Pool-Datei
INSERT INTO media_files (path, is_pool_file, category)
VALUES ('local/media-pool/shared/2025/01/abc123.jpg', true, 'pool');

-- Kontext-Datei (dupliziert)
INSERT INTO media_files (path, is_pool_file, category, hash)
VALUES ('local/internal/hcm/123/2025/01/def456.jpg', false, 'hcm', 'same_hash_as_pool');
```

### Livewire Components

[](#livewire-components)

#### Media Pool Manager

[](#media-pool-manager)

- **Übersicht**: Alle Pool-Dateien mit Filterung
- **Upload**: Drag &amp; Drop Upload in Pool
- **Verwendung**: Dateien in Kontexte duplizieren
- **Löschung**: Pool-Dateien verwalten

#### Media Selector (für andere Module)

[](#media-selector-für-andere-module)

- **Pool-Browse**: Durchsuchen verfügbarer Pool-Dateien
- **Upload**: Neue Dateien direkt hochladen
- **Duplikation**: Pool-Dateien in Kontext duplizieren
- **Vorschau**: Bild-Preview und Meta-Informationen

### Service Functions

[](#service-functions)

#### storeToPool()

[](#storetopool)

```
$mediaFile = $mediaService->storeToPool($uploadedFile, [
    'description' => 'Logo für Website',
    'tags' => ['logo', 'branding']
]);
```

#### duplicateFromPool()

[](#duplicatefrompool)

```
$contextFile = $mediaService->duplicateFromPool($poolFile, 'hcm', [
    'attached_to' => 'employee_profile',
    'employee_id' => 123
]);
```

#### Event: MediaDuplicatedFromPool

[](#event-mediaduplicatedfrompool)

```
Event::listen(MediaDuplicatedFromPool::class, function ($event) {
    Log::info("Datei dupliziert", [
        'pool_file' => $event->poolFile->id,
        'context_file' => $event->contextFile->id,
        'context' => $event->context
    ]);
});
```

🔧 Verwendung in anderen Modulen
-------------------------------

[](#-verwendung-in-anderen-modulen)

### HCM Module

[](#hcm-module)

```
use Platform\Media\Traits\HasMedia;

class Employee extends Model
{
    use HasMedia;

    public function mediaStorageModelSegment(): string
    {
        return 'hcm';
    }

    public function mediaStorageIdSegment(): string
    {
        return $this->id;
    }
}

// Verwendung
$employee = Employee::find(1);
$mediaFile = $mediaService->duplicateFromPoolToModel($poolFile, $employee);
```

### Food Service Module

[](#food-service-module)

```
class Recipe extends Model
{
    use HasMedia;

    public function mediaStorageModelSegment(): string
    {
        return 'food-service';
    }

    public function mediaStorageExtraSegments(): array
    {
        return ['recipes'];
    }
}
```

### OKR Module

[](#okr-module)

```
class Objective extends Model
{
    use HasMedia;

    public function mediaStorageModelSegment(): string
    {
        return 'okr';
    }
}
```

🎨 UI Integration
----------------

[](#-ui-integration)

### Media Selector Component

[](#media-selector-component)

```
// In anderen Livewire Components
use Platform\Media\Livewire\MediaSelector;

class EmployeeForm extends Component
{
    public function render()
    {
        return view('livewire.employee.form', [
            'mediaSelector' => MediaSelector::class
        ]);
    }
}
```

### Blade Template

[](#blade-template)

```

    Profilbild
    @livewire('media-selector', [
        'model' => $employee,
        'role' => 'profile_image'
    ])

```

📁 Datenbank-Schema
------------------

[](#-datenbank-schema)

### media\_mime\_types

[](#media_mime_types)

```
CREATE TABLE media_mime_types (
    id BIGINT PRIMARY KEY,
    mime_type VARCHAR(255) UNIQUE,
    description VARCHAR(255),
    extension VARCHAR(10),
    is_image BOOLEAN,
    is_video BOOLEAN,
    is_document BOOLEAN,
    is_audio BOOLEAN,
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);
```

### media\_files

[](#media_files)

```
CREATE TABLE media_files (
    id BIGINT PRIMARY KEY,
    disk VARCHAR(50),
    path VARCHAR(500),
    original_name VARCHAR(255),
    hash VARCHAR(64) UNIQUE,
    mime_type_id BIGINT,
    file_size BIGINT,
    meta JSON,
    width INTEGER,
    height INTEGER,
    is_pool_file BOOLEAN,
    category VARCHAR(100),
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);
```

### media\_attachments

[](#media_attachments)

```
CREATE TABLE media_attachments (
    id BIGINT PRIMARY KEY,
    attachable_type VARCHAR(255),
    attachable_id BIGINT,
    media_file_id BIGINT,
    role VARCHAR(100),
    position INTEGER,
    realm VARCHAR(50),
    access_scope_type VARCHAR(255),
    access_scope_id BIGINT,
    meta JSON,
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);
```

### media\_image\_variants

[](#media_image_variants)

```
CREATE TABLE media_image_variants (
    id BIGINT PRIMARY KEY,
    media_file_id BIGINT,
    variant_name VARCHAR(100),
    file_path VARCHAR(500),
    file_size BIGINT,
    width INTEGER,
    height INTEGER,
    format VARCHAR(10),
    quality INTEGER,
    meta JSON,
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);
```

🔧 Konfiguration
---------------

[](#-konfiguration)

### config/media.php

[](#configmediaphp)

```
return [
    'storage' => [
        'disk' => env('MEDIA_DISK', 'wasabi'),
        'prefixes' => [
            'public' => '{env}/public',
            'internal' => '{env}/internal',
            'private' => '{env}/private',
            'pool' => '{env}/media-pool/shared',
        ],
        'image_variants' => [
            'formats' => [
                '4_3' => [300, 225, 800, 600, 1200, 900, 2400, 1800],
                '16_9' => [300, 169, 800, 450, 1200, 675, 2400, 1350],
                '1_1' => [300, 300, 800, 800, 1200, 1200, 2400, 2400],
                '9_16' => [300, 533, 800, 1422, 1200, 2133, 2400, 4267],
                '3_1' => [300, 100, 900, 300, 1500, 500, 3000, 1000],
                'original' => [300, null, 800, null, 1200, null, 2400, null],
            ],
            'format' => 'webp',
            'quality' => 90,
        ],
    ],
    'upload' => [
        'max_size' => env('MEDIA_MAX_SIZE', 50 * 1024 * 1024),
        'allowed_mimes' => [
            'image/jpeg', 'image/png', 'image/gif', 'image/webp',
            'video/mp4', 'video/avi', 'video/mov',
            'audio/mpeg', 'audio/wav', 'audio/ogg',
            'application/pdf', 'application/msword',
            // ... weitere MIME-Types
        ],
    ],
];
```

🚀 Roadmap
---------

[](#-roadmap)

### Phase 1: Basis-Funktionalität ✅

[](#phase-1-basis-funktionalität-)

- Service-Architektur mit Contracts
- Upload-Funktionalität (Pool + Kontext)
- Bildvarianten-Generierung
- Livewire Upload-Komponente
- Dashboard und UI

### Phase 2: Erweiterte Features

[](#phase-2-erweiterte-features)

- FilePond-ähnliche Upload-Experience
- Image Cropping und Editing
- Batch-Uploads und Chunked Uploads
- Drag &amp; Drop zwischen Modulen
- Erweiterte Suche und Filterung

### Phase 3: Advanced Features

[](#phase-3-advanced-features)

- AI-basierte Bildanalyse
- Automatische Tagging
- Duplikatserkennung mit visueller Ähnlichkeit
- CDN-Integration
- Backup und Recovery

📝 Changelog
-----------

[](#-changelog)

### v1.0.0

[](#v100)

- Initiale Version mit Service-Architektur
- Upload-Funktionalität (Pool + Kontext)
- Bildvarianten-Generierung
- Livewire Integration
- Dashboard und UI
- MIME-Type Management
- Polymorphe Beziehungen

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance57

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/624263472b888cbddf2459047c1ab71dafd2a5875da576e3675b9c3584dad922?d=identicon)[martin3r](/maintainers/martin3r)

---

Top Contributors

[![martin3r-me](https://avatars.githubusercontent.com/u/187852765?v=4)](https://github.com/martin3r-me "martin3r-me (2 commits)")

### Embed Badge

![Health badge](/badges/martin3r-platform-media/health.svg)

```
[![Health](https://phpackages.com/badges/martin3r-platform-media/health.svg)](https://phpackages.com/packages/martin3r-platform-media)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
