djvue/d-media-bundle

Symfony bundle for d-media package

Installs: 161

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.9.10 2022-06-05 22:43 UTC

This package is auto-updated.

Last update: 2025-03-07 01:19:08 UTC


README

Introduction

Symfony D-Media Bundle is a package that provides JSON REST HTTP API for frontend media manager library and services to use Medias on backend.

Frontend Package: vue-d-media

Usage example: symfony-d-media-bundle-example

Usage example demo: demo

Installation

Install with composer

composer require djvue/d-media-bundle

Requires PHP >=8.0 and Symfony >=5.2

You may also need to install frontend components. See instruction in frontend repository vue-d-media.

Getting started

  • Add bundle

config/bundles.php

return [
    ...,
    Djvue\DMediaBundle\DMediaBundle::class => ['all' => true],
];
  • Import routes

config/routes.yaml

media:
    resource: '@DMediaBundle/Resources/config/routes/media.yaml'
    prefix: '/api/media' #your prefix equal to frontend library api.config.prefix
    trailing_slash_on_root: false
    name_prefix: board_media_
  • Configure (optional)

config/packages/d_media.yaml

d_media:
    filterable_entities:
        - workspace
    storage:
        public_url: /storage/medias
        directory: /uploads
    library:
        image_extensions: png, jpg, jpeg, webp

Help services

SomeClass.php

public function __construct(
    private MediaService $mediaService,
    private MediaEntityService $mediaEntityService,
) {
}

Security

Bundle controller uses symfony/security. To control access add voters: MediaVoter and MediaGetListVoter.

See example in symfony example repository symfony-d-media-bundle-example