GithubHelp home page GithubHelp logo

api-media's Introduction

API Media implementation

Based on amazing work of https://github.com/benjaminrau/media-api

Dependencies

  • api-platform/core
  • Symfony 3.x
  • sonata-project/media-bundle 3.8

Setup

  1. Install dependencies

  2. copy file into your src/MediaBundle

  3. Register the bundle into you composer.json (autoload) and AppKernel.php

    new MediaBundle\MediaBundle(),

Configuration file

app/config/sonata_media.yml

sonata_media:
    force_disable_category: true
    class:
        media: MediaBundle\Entity\Media
    #    gallery: MyVendor\MediaBundle\Entity\Gallery
    #    gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
    db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
    default_context: image # you need to set a context
    #providers:
    #    image:
    #        thumbnail:  sonata.media.thumbnail.liip_imagine
    contexts:
        default:  # the default context is mandatory
            providers:
                - sonata.media.provider.file
                - sonata.media.provider.image
                - sonata.media.provider.youtube
                - sonata.media.provider.vimeo

            formats:
                small: { width: 100 , quality: 70}
                big:   { width: 500 , quality: 70}
        image:
            providers:
                - sonata.media.provider.image
            formats:
                small: { width: 100 , quality: 70}
                big:   { width: 500 , quality: 70}
    cdn:
        server:
            path: /uploads # http://media.sonata-project.org/

    filesystem:
        local:
            directory:  "%kernel.root_dir%/../web/uploads"
            create:     false

Autowiring: app/config/services.yml

    [...]

    MediaBundle\:
        resource: '../../src/MediaBundle/*'
        # you can exclude directories or files
        # but if a service is unused, it's removed anyway
        exclude: '../../src/MediaBundle/{Entity,Repository}'

    # controllers are imported separately to make sure they're public
    # and have a tag that allows actions to type-hint services

    [...]

    MediaBundle\Action\:
        resource: '../../src/MediaBundle/Action'
        public: true
        tags: ['controller.service_arguments']

    [...]

api-media's People

Contributors

nightbr avatar

Stargazers

Fabian Steiner avatar Nicolas F. avatar

Watchers

James Cloos avatar  avatar Gaetan D avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.