seraph / media-bundle
Media Bundle is a solution to manage a multimedia library.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.0
- symfony/console: ^4.0
- symfony/flex: ^1.0
- symfony/form: ^4.0
- symfony/framework-bundle: ^4.0
- symfony/lts: ^4@dev
- symfony/orm-pack: ^1.0
- symfony/swiftmailer-bundle: ^3.2
- symfony/templating: ^4.0
- symfony/twig-bundle: ^4.0
- symfony/yaml: ^4.0
- vich/uploader-bundle: ^1.8
This package is not auto-updated.
Last update: 2024-04-20 13:24:25 UTC
README
This bundle is a solution to manage a media library, with back end system, and twig function for the front display.
How it works
This bundle VichUploaderBundle to work.
The back end system use bootstrap 4 to display all templates.
The MediaBundle provide some entities, controllers, forms and twig extension.
To read more about the using of this bundle, we invite you to check the docs.
Installation
-
Install it using composer
$ composer require seraph/media-bundle
-
Add SeraphMediaBundle configuration
# app/config/packages/seraph_media.yaml seraph_media: user_class: App\Entity\User group_class: App\Entity\Group # upload_folder: /uploads/
-
Add routing of the bundle
# app/config/routes.yaml seraph_media: resource: '@SeraphMediaBundle/Controller' type: annotation # prefix: '/admin'
-
Update your database with User, Group and UploadedFile
$ php bin/console doctrine:schema:update --force
Using
In this example I use FosUserBundle but you can use another bundle or your own classes.
-
Implement UserInterface
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; // ... }
-
Implement GroupInterface
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 :