2017 © Pedro Peláez
 

symfony-bundle media-bundle

Media Bundle is a solution to manage a multimedia library.

image

seraph/media-bundle

Media Bundle is a solution to manage a multimedia library.

  • Friday, July 27, 2018
  • by sERAPH1
  • Repository
  • 0 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SeraphMediaBundle

This bundle is a solution to manage a media library, with back end system, and twig function for the front display., (*1)

How it works

This bundle VichUploaderBundle to work., (*2)

The back end system use bootstrap 4 to display all templates., (*3)

The MediaBundle provide some entities, controllers, forms and twig extension., (*4)

To read more about the using of this bundle, we invite you to check the docs., (*5)

Installation

  1. Install it using composer, (*6)

    $ composer require seraph/media-bundle
    
  2. Add SeraphMediaBundle configuration, (*7)

    # app/config/packages/seraph_media.yaml
    
    seraph_media:
        user_class: App\Entity\User
        group_class: App\Entity\Group
        # upload_folder: /uploads/
    
  3. Add routing of the bundle, (*8)

    # app/config/routes.yaml   
    
    seraph_media:
        resource: '@SeraphMediaBundle/Controller'
        type: annotation
        # prefix: '/admin' 
    
  4. Update your database with User, Group and UploadedFile, (*9)

    $ php bin/console doctrine:schema:update --force
    

Using

In this example I use FosUserBundle but you can use another bundle or your own classes., (*10)

  1. Implement UserInterface, (*11)

    use FOS\UserBundle\Model\User as BaseUser;
    use Doctrine\ORM\Mapping as ORM;
    use Seraph\Bundle\MediaBundle\Model\UserInterface;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="user")
     */
    class User extends BaseUser implements UserInterface
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        protected $firstname;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        protected $name;
    
        /**
         * @ORM\ManyToMany(targetEntity="App\Entity\Group")
         * @ORM\JoinTable(name="user_group_user",
         *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
         *      inverseJoinColumns={@ORM\JoinColumn(name="group_user_id", referencedColumnName="id")}
         * )
         */
        protected $groups;
    
        /**
         * @ORM\OneToMany(targetEntity="Seraph\Bundle\MediaBundle\Entity\UploadedFile", mappedBy="user")
         */
        protected $files;
    
        // ...
    }
    
  2. Implement GroupInterface, (*12)

    use FOS\UserBundle\Model\Group as BaseGroup;
    use Doctrine\ORM\Mapping as ORM;
    use Seraph\Bundle\MediaBundle\Model\GroupInterface;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="group_user")
     */
    class Group extends BaseGroup implements GroupInterface
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;
    
        /**
         * @ORM\OneToMany(targetEntity="Seraph\Bundle\MediaBundle\Entity\UploadedFile", mappedBy="group")
         */
        protected $files;
    
        // ...
     }
    

Documentation

You can find in this folder, how you can use the bundle :, (*13)

The Versions