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

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

opifer/media-bundle
===================

Opifer Media Bundle

0.1.3(10y ago)86.8k22MITPHPPHP &gt;=5.4

Since May 14Pushed 10y ago8 watchersCompare

[ Source](https://github.com/Opifer/MediaBundle)[ Packagist](https://packagist.org/packages/opifer/media-bundle)[ Docs](https://github.com/Opifer/MediaBundle)[ RSS](/packages/opifer-media-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (4)Dependencies (13)Versions (6)Used By (2)

[![Build Status](https://camo.githubusercontent.com/0c8aa99eb9a35bd9736d3482c54237caa5466872eaf71d6501a4115e72542814/68747470733a2f2f7472617669732d63692e6f72672f4f70696665722f4d6564696142756e646c652e737667)](https://travis-ci.org/Opifer/MediaBundle)[![SensioLabsInsight](https://camo.githubusercontent.com/693d0ca13aa44a8fbee00a94046b9f0c89af7ce2579b2cd328a07a179f03930b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37626162363563652d313437622d343134382d393062322d3831656138343534656266302f6d696e692e706e67)](https://insight.sensiolabs.com/projects/7bab65ce-147b-4148-90b2-81ea8454ebf0)

MediaBundle
===========

[](#mediabundle)

A Symfony Media Manager. Inspired by SonataMediaBundle's use of Media Providers to add different Media types.

Note: This bundle is still very much a work in progress, so BC-breaks will happen until the first stable release.

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

[](#installation)

Install `FOSJsRoutingBundle` according to it's [documentation](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/doc/index.md)

Add the bundle to your `composer.json`

```
composer require opifer/media-bundle dev-master

```

Register the bundle and its dependencies in `app/AppKernel.php`

```
public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
        new Liip\ImagineBundle\LiipImagineBundle(),
        new Opifer\MediaBundle\OpiferMediaBundle()
    );
}
```

You should create your own Media entity that extends `Opifer\MediaBundle\Model\Media`.

```
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Opifer\MediaBundle\Model\Media as BaseMedia;

/**
 * @ORM\Table(name="media")
 * @ORM\Entity(repositoryClass="Opifer\MediaBundle\Model\MediaRepository")
 */
class Media extends BaseMedia
{
    // Add custom functionality...
}
```

And reference to it in your `app/config/config.yml`

```
opifer_media:
    media_class: AppBundle\Entity\Media
```

Using the media manager
-----------------------

[](#using-the-media-manager)

This bundle comes with an AngularJS media manager included. To use it, you'll need to include some necessary javascript files and CSS files into your templates.

First, make sure you installed all asset dependencies. You can download them manually, copy the `bower.json` file to your own bundle and run `bower install` or copy the `bower.json` content to your own bower dependencies.

Then, add the dependencies to your templates.

```
{% stylesheets
    'bundles/opifermedia/css/dropzone.less'
    'bundles/opifermedia/css/main.less'

    filter='less,cssrewrite' %}

{% endstylesheets %}

...

{% javascripts
    '@AppBundle/Resources/public/components/ng-file-upload/angular-file-upload-shim.min.js'
    '@AppBundle/Resources/public/components/angular/angular.js'
    '@AppBundle/Resources/public/components/angular-route/angular-route.js'
    '@AppBundle/Resources/public/components/angular-resource/angular-resource.js'
    '@AppBundle/Resources/public/components/ngInfiniteScroll/build/ng-infinite-scroll.js'
    '@AppBundle/Resources/public/components/ng-file-upload/angular-file-upload.min.js'

    '@OpiferMediaBundle/Resources/public/js/dropzone.js'
    '@OpiferMediaBundle/Resources/public/app/modal/modal.js'
    '@OpiferMediaBundle/Resources/public/app/medialibrary/medialibrary.js'

    'bundles/fosjsrouting/js/router.js' %}

{% endjavascripts %}
```

Then, create an Angular module that requires the following modules:

```
'use strict';

angular.module('App', [
    'ngRoute',
    'ngResource',
    'mediaLibrary',
    'angularFileUpload',
]);
```

Make sure you add the angular module in your template by adding the the file to your `{% javascripts %}` list. And initialize the Angular `App` in your template:

```

```

To make the mediamanager accessible in the browser, add the routes to your `routing.yml`:

```
opifer_media:
    resource: "@OpiferMediaBundle/Resources/config/routing.yml"
    prefix:   /admin

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"
    options:
        expose: true
```

To use the mediamanager in your own layout, override `OpiferMediaBundle::base.html.twig`:

```
{# app/Resources/OpiferMediaBundle/views/base.html.twig #}
{% extends 'base.html.twig' %}

{% block body %}
	{% block opifer_media_body %}{% endblock %}
{% endblock %}

{% block javascripts %}
    {{ parent() }}

    {% block opifer_media_javascripts %}{% endblock %}
{% endblock %}
```

Adding a mediapicker to a form
------------------------------

[](#adding-a-mediapicker-to-a-form)

Create a relationship between the media entity and any other entity. For example, Users must be able to add media to a Content item.

```
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Opifer\MediaBundle\Model\MediaInterface;

class Content
{
    /**
     * @var Media
     *
     * @ORM\ManyToOne(targetEntity="Opifer\MediaBundle\Model\MediaInterface")
     * @ORM\JoinColumn(name="media_id", referencedColumnName="id", onDelete="SET NULL")
     */
    protected $image;

    /**
     * Set image
     *
     * @param string $image
     *
     * @return Content
     */
    public function setImage(MediaInterface $image = null)
    {
        $this->image = $image;

        return $this;
    }

    /**
     * Get image
     *
     * @return MediaInterface
     */
    public function getImage()
    {
        return $this->image;
    }
}
```

In your content FormType, add the `mediapicker` form type:

```
namespace AppBundle\Form\Type;

use Doctrine\ORM\EntityRepository;
use Opifer\MediaBundle\Form\Type\MediaPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class ContentType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            // ...
            ->add('image', MediaPickerType::class, [
                'multiple' => false,
            ])
        ;
    }
}
```

Documentation
-------------

[](#documentation)

- [Configuration reference](Resources/doc/configuration-reference.md)
- [Media providers](Resources/doc/providers.md)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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 ~71 days

Total

5

Last Release

3734d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6866d9d11ab5b172391449a5751e5b7cc8840792a31d892e225e22bcd779d5ce?d=identicon)[rvanlaarhoven](/maintainers/rvanlaarhoven)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[pumukit/pumukit

Media Portal

5714.0k37](/packages/pumukit-pumukit)

PHPackages © 2026

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