Download the PHP package netbull/media-bundle without Composer

On this page you can find all versions of the php package netbull/media-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package media-bundle

NetBull MediaBundle

A Symfony bundle for managing media — images, files and video providers (YouTube, Vimeo, Youku) — with pluggable storage (local filesystem or Amazon S3), thumbnail generation and configurable access-control strategies for downloads/views. Originally a trimmed fork of SonataMediaBundle.

Installation

Register the bundle

With Symfony Flex this is automatic. Otherwise add it to config/bundles.php:

Import the routes

The download/view endpoints live in the bundle. Add to config/routes.yaml:

This registers netbull_media_view (/media/view/{id}/{format}) and netbull_media_download (/media/download/{id}/{format}).

Configuration

Create config/packages/netbull_media.yaml. A minimal local-development setup:

Each context declares which providers it accepts, its image formats, and the download/view security strategy. See docs/example_config.yaml for a full, annotated example (multiple contexts, S3, signed URLs, custom strategies).

Available services

Kind Service id
Providers netbull_media.provider.image, .file, .youtube, .vimeo, .youku
Filesystems netbull_media.filesystem.local, netbull_media.filesystem.s3
CDN netbull_media.cdn.server, netbull_media.cdn.local.server
Security strategies netbull_media.security.public_strategy, .forbidden_strategy, .superadmin_strategy, .connected_strategy, .hash_strategy

Upload restrictions — each provider's allowed_extensions / allowed_mime_types are enforced on upload using the file's sniffed content (not the client-supplied name/type). A file is accepted only if it matches at least one of the configured lists.

S3 ACL — default to acl: private and serve public assets through the CDN; a public-read ACL makes objects world-readable and bypasses the bundle's download/view security strategies.

Secured downloads — for contexts behind a download/view security strategy, S3-backed media is served according to the context's download.mode / view.mode:

  • stream (default) — the bytes are proxy-streamed through PHP in constant memory (lazy S3 GetObject, not the buffering Gaufrette adapter), returning a same-origin 200 so SPA clients can fetch it over XHR (no cross-origin redirect → no CORS).
  • redirect — the client is sent a short-lived (300s) pre-signed S3 URL, so the file streams S3 → client and never passes through PHP (best for large files).

Local storage always streams the file in chunks. Either way the access-control check runs in the controller before the response is issued.

Video providers (SSRF) — video providers fetch oEmbed metadata and remote thumbnails over HTTP. Thumbnail URLs are validated before fetching (http/https to public hosts only; private, loopback and cloud-metadata addresses are refused) and redirects are disabled. To route this egress through your own controls, enable framework.http_client and the bundle will use the configured client.

Thumbnail generation (sync or async)

By default thumbnails are generated in-process when the media is flushed. To offload resizing to a worker, enable the async strategy:

Optional dependency — async mode needs the Messenger component, which the bundle treats as an optional (suggested) dependency. Install it before enabling async:

The message handler is only registered when symfony/messenger is installed, and enabling thumbnail.async: true without it fails fast with a clear error at container compile time. In the default sync mode the bundle works without Messenger.

When async: true, the bundle dispatches a NetBull\MediaBundle\Message\GenerateThumbnailMessage per format to the Messenger bus. Route it to an async transport so a worker does the resizing (worker recycling provides the memory isolation that long-running image processing needs):

With no transport routing configured, Messenger handles the message synchronously, so async mode is safe to enable before you have a worker.

Usage

Attach media to your entity

The bundle ships a mapped NetBull\MediaBundle\Entity\Media entity — reference it from your own entities:

Upload

Set the binary content and the provider/context, then persist. The bundle's Doctrine listener transforms the upload, stores it and generates thumbnails on flush:

In forms, use NetBull\MediaBundle\Form\Type\MediaType (or MediaShortType) with the provider and context options.

Render in Twig

The bundle registers these Twig filters:

Autowiring

Console commands

Command Description
netbull:media:create-thumbnail <id> [format] Generate a thumbnail for one media
netbull:media:resize [context] Generate missing thumbnails
netbull:media:sync-thumbnails Regenerate thumbnails
netbull:media:clone <id> Clone a media (and its stored file)

Development

License

MIT


All versions of media-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-curl Version *
ext-gd Version *
aws/aws-sdk-php Version 3.*
doctrine/collections Version ^2.1
doctrine/dbal Version ^3.7|^4.0
doctrine/doctrine-bundle Version ^2.12|^3.0
doctrine/orm Version ^2.20|^3.0
doctrine/persistence Version ^3.1|^4.0
imagine/imagine Version 1.*
knplabs/gaufrette Version 0.9.*
psr/log Version ^3.0
symfony/config Version 7.4.*
symfony/console Version 7.4.*
symfony/dependency-injection Version 7.4.*
symfony/event-dispatcher Version 7.4.*
symfony/form Version 7.4.*
symfony/framework-bundle Version 7.4.*
symfony/http-client Version 7.4.*
symfony/http-foundation Version 7.4.*
symfony/http-kernel Version 7.4.*
symfony/mime Version 7.4.*
symfony/options-resolver Version 7.4.*
symfony/process Version 7.4.*
symfony/routing Version 7.4.*
symfony/security-bundle Version 7.4.*
symfony/security-core Version 7.4.*
symfony/twig-bundle Version 7.4.*
symfony/yaml Version 7.4.*
twig/twig Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package netbull/media-bundle contains the following files

Loading the files please wait ...