PHPackages                             symkit/media-bundle - 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. symkit/media-bundle

ActiveSymfony-bundle[Image &amp; Media](/categories/media)

symkit/media-bundle
===================

A powerful, modern media management bundle for Symfony applications, designed for performance, flexibility, and a premium UI/UX.

v0.0.4(2mo ago)0401MITPHPPHP &gt;=8.2CI failing

Since Feb 22Pushed 2mo agoCompare

[ Source](https://github.com/SymKit/media-bundle)[ Packagist](https://packagist.org/packages/symkit/media-bundle)[ RSS](/packages/symkit-media-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (17)Versions (5)Used By (1)

Symkit Media Bundle
===================

[](#symkit-media-bundle)

[![CI](https://github.com/symkit/media-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/symkit/media-bundle/actions)[![Latest Version](https://camo.githubusercontent.com/2e5a9dc028c66323aa094908d9784dfc1619647698674aa0e03ffbd546095c5a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73796d6b69742f6d656469612d62756e646c652e737667)](https://packagist.org/packages/symkit/media-bundle)[![PHPStan Level 9](https://camo.githubusercontent.com/1bc07920f0d36e55c17e1d38b1caa132cc605f51a82b388c962870b9a747b898/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e737667)](https://phpstan.org/)

A powerful, modern media management bundle for Symfony applications, designed for performance, flexibility, and a premium UI/UX.

Features
--------

[](#features)

- **Async Uploads**: Fast, asynchronous file uploads via dedicated API endpoint.
- **Advanced Security Layer**: Modular security strategy pattern to block threats (Magic Bytes, SVG sanitization, pixel/archive bomb protection, MIME consistency).
- **File Processing**: EXIF stripping, strict file permissions.
- **Media Library**: Grid-based library with search and pagination (Live Component).
- **Media Picker**: Form field for selecting and replacing media assets.
- **SOLID &amp; Configurable**: Activable admin/API, configurable entity and repository, routes via YAML.
- **Translations**: FR and EN included; domain `SymkitMediaBundle`.
- **Hotwired Stack**: Symfony UX Live Components and Stimulus.

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require symkit/media-bundle
```

### 2. Register the Bundle

[](#2-register-the-bundle)

In `config/bundles.php`:

```
return [
    // ...
    Symkit\MediaBundle\SymkitMediaBundle::class => ['all' => true],
];
```

### 3. Configuration

[](#3-configuration)

Create `config/packages/symkit_media.yaml`:

```
symkit_media:
    public_dir: '%kernel.project_dir%/public'
    media_prefix: '/uploads/media/'
    alt_text_strategy: 'Symkit\MediaBundle\Strategy\FilenameAltTextStrategy'

    admin:
        enabled: true
        route_prefix: 'admin'   # URL prefix for admin routes (e.g. /admin/media)

    api:
        enabled: true          # Async upload endpoint

    doctrine:
        entity: 'Symkit\MediaBundle\Entity\Media'
        repository: 'Symkit\MediaBundle\Repository\MediaRepository'

    search:
        enabled: true           # Register MediaSearchProvider for symkit/search-bundle
        engine: 'default'       # Search engine to attach the provider to
```

### 4. Routes

[](#4-routes)

Include the bundle routes in `config/routes.yaml`:

```
# Admin (list, create, edit, delete)
symkit_media_admin:
    resource: '@SymkitMediaBundle/config/routing_admin.yaml'
    prefix: '%symkit_media.admin.route_prefix%'

# API (async upload)
symkit_media_api:
    resource: '@SymkitMediaBundle/config/routing_api.yaml'
    prefix: /admin/medias/api
```

If `admin.enabled` or `api.enabled` is `false`, do not include the corresponding route block so that those URLs are not exposed.

### 5. Assets

[](#5-assets)

The bundle prepends its Stimulus controllers to AssetMapper. Ensure your app discovers them (e.g. via `assets/bootstrap.js` and Stimulus).

Activation / Deactivation
-------------------------

[](#activation--deactivation)

- **Disable admin**: Set `admin.enabled: false` and remove or do not load the `symkit_media_admin` routes.
- **Disable API**: Set `api.enabled: false` and remove or do not load the `symkit_media_api` routes.
- **Disable search**: Set `search.enabled: false` to avoid registering the media search provider with [symkit/search-bundle](https://packagist.org/packages/symkit/search-bundle). No attributes are used; the provider is registered via the bundle’s PHP config (tag `symkit_search.provider`).

Only the controllers, routes, and search provider are conditional; core services (MediaManager, forms, Live Components, etc.) remain available when the bundle is enabled.

Custom Entity and Repository
----------------------------

[](#custom-entity-and-repository)

You can use your own Media entity and repository:

1. Create an entity (e.g. extend `Symkit\MediaBundle\Entity\Media` or implement the same contract) and map it with Doctrine.
2. Create a repository that implements `Symkit\MediaBundle\Repository\MediaRepositoryInterface` (or extend `Symkit\MediaBundle\Repository\MediaRepository` with a constructor accepting `ManagerRegistry` and `string $entityClass`).
3. Configure:

```
symkit_media:
    doctrine:
        entity: 'App\Entity\Media'
        repository: 'App\Repository\MediaRepository'
```

Translations (FR / EN)
----------------------

[](#translations-fr--en)

The bundle ships with English and French in `translations/` (domain `SymkitMediaBundle`). The translation path is registered automatically.

- Set your app locale in `config/packages/framework.yaml` (`default_locale`, `enabled_locales`) and use the translator as usual.
- All admin labels, form labels, library and picker UI, and API error messages use this domain.

Usage
-----

[](#usage)

### In Entities

[](#in-entities)

```
use Symkit\MediaBundle\Entity\Media;

#[ORM\ManyToOne(targetEntity: Media::class)]
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?Media $image = null;
```

### In Forms

[](#in-forms)

```
use Symkit\MediaBundle\Form\MediaType;

$builder->add('image', MediaType::class);
```

### In Twig

[](#in-twig)

```

```

Architecture &amp; SOLID
------------------------

[](#architecture--solid)

- **MediaManager**: Orchestrates upload (Security → Processing → Storage → Metadata).
- **MediaRepositoryInterface**: Implement or extend the default repository for custom entity/repository.
- **SecurityRuleInterface**: Tag with `symkit_media.security_rule` for custom security rules.
- **FileProcessorInterface**: Tag with `symkit_media.processor` for custom processors.
- **StorageInterface**: Swap storage backends (Local, S3, etc.).
- **AltTextStrategyInterface**: Customize alt text generation.

Testing
-------

[](#testing)

### Bundle test suite

[](#bundle-test-suite)

From the bundle root, run `make test`. After `composer install`, you can also run `make quality` for the full pipeline (cs-check, phpstan, deptrac, lint, test, infection).

The suite includes unit tests (services, form transformer, security rules, Live Components, search provider), integration tests (bundle boot, config, services), and functional tests (API upload).

### Testing in an application

[](#testing-in-an-application)

To validate the bundle in a real application (e.g. an app that uses this bundle via Composer):

1. **Run the application** (e.g. `symfony serve` or `php -S localhost:8000 -t public` from the app root).
2. **Admin media**
    - Open the media list (e.g. `/admin/media` if `route_prefix` is `admin`).
    - Check: list, create (upload), edit (replace file), delete.
3. **API upload**
    - POST a file to the async upload endpoint (e.g. `/admin/medias/api/upload` with `file`).
    - Expect JSON `{ "id", "url", "filename" }` on success.
4. **Media Library / Picker**
    - Use a form that embeds the media library or picker Live Component; run search, pagination, and selection.
5. **Search**
    - If the app uses symkit/search-bundle, trigger global search and confirm media results appear.

These steps can be automated with E2E tools (e.g. Playwright, Mink) or run as a manual checklist.

Contributing
------------

[](#contributing)

- Run the quality pipeline: `make quality` (or `make cs-fix`, `make phpstan`, `make test`).

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance83

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

85d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/077eba6702dc23a795ee2262dff92505e3c8ead08f7cb205be80d8aae0a6b8e5?d=identicon)[sdieunidou](/maintainers/sdieunidou)

---

Top Contributors

[![sdieunidou](https://avatars.githubusercontent.com/u/570763?v=4)](https://github.com/sdieunidou "sdieunidou (8 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/symkit-media-bundle/health.svg)

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

###  Alternatives

[fmonts/ffmpeg-bundle

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/PHP-FFMpeg/PHP-FFMpeg/)

12195.1k](/packages/fmonts-ffmpeg-bundle)[snowcap/im-bundle

Imagemagick wrapper for Symfony2

2347.0k1](/packages/snowcap-im-bundle)[mezcalito/imgproxy-bundle

115.7k2](/packages/mezcalito-imgproxy-bundle)

PHPackages © 2026

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