Download the PHP package ranky/media-bundle without Composer

On this page you can find all versions of the php package ranky/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

MediaBundle (Media File Manager for Symfony)

CI

MediaBundle is a media file manager bundle for Symfony with a REST API and an admin interface (React). It provides a clean and user-friendly way to upload, edit and delete files. It supports multiple formats. You can upload images, videos, audios, documents, zip files, etc.

MediaBundle automatically compress your media files to reduce their size without sacrificing quality. Additionally, it offers the ability to resize your media files to fit specific dimensions (breakpoints), making it easy to ensure that your images are the correct size for your website.

MediaBundle also integrates with your database to store and manage your media files efficiently. This means you can keep track of all your media assets in one place, similar to how WordPress manages media files. This way, you can have all your media files organized and accessible in one place.

Table of Contents

Video

https://user-images.githubusercontent.com/2461400/208309129-280d4fdb-d3f5-4cb7-bd32-175db6bb6f70.mp4

https://user-images.githubusercontent.com/2461400/208732093-44cf5a21-62f9-4402-bbcf-0cffa4aa56f6.mp4

Advantages

Features

Requirements

Imagick extension

Requirements

Imagick extension requires the imagemagick library installed in your system. If you are not going to use Docker remember that many distros come with outdated imagemagick and no WebP support. Most likely you will have to compile it manually:

Ubuntu example

Docker: Dockerfile

Install Imagick extension

Case Docker

Dockerfile

Case Pecl
Enable the extension if it is not done automatically 👀
Verify Installation

Compression Tools

None of these tools is mandatory; it already depends on the need to optimize the images or not.

Dockerfile

Installation

While I create the recipes for Symfony Flex, here are the steps to follow:

Step 1: Enable the bundle in the kernel

Although this step should be done automatically.

Step 2: Import the routes

YAML

PHP

Step 3: Create the following file and configure it for your application.

The minimum required configuration is provided, in the configuration you will see all the options.

YAML

PHP

Step 4 (Optional): Add custom Dbal types

Currently, the LoadClassMetadata event is responsible for loading custom DBAL types. If this event does not work, you can add custom functions manually using the following examples:

Note: This Event Subscriber may be removed in the future.

PHP

YAML

Step 5: Schema update and assets install

Configuration

Full configuration with default values

All options are optional, but user_entity is necessary to configure if you do not want to include guest users in the user filter.

Configuration Explanation

user_entity (string, default: null)

This is the fully qualified class name (FQCN) of the user entity class. This is required in order to get the username in case you are using a different UserIdentifier and in that way to be able to filter media by user.

Example: User::class

user_identifier_property (string, default: username)

This is the property of the user entity that contains the user identifier. This is required if it is different from the username.

date_time_format (string, default: Y-m-d H:i)

This is the format in which the creation and update date of a media are displayed in the list view and in the media modal.

api_prefix (string, default: null)

This is mandatory if you want to import bundle routes with a prefix like "/admin", to follow some kinds of convention in your admin or panel.

See more in the security section

This configuration will also create a global twig variable (ranky_media_api_prefix) that you can use later in your templates.

Example: /admin

upload_directory (string, default: %kernel.project_dir%/public/uploads)

This is the directory where uploaded files will be stored.

Example: %kernel.project_dir%/public/uploads

upload_url (string, default: /uploads)

This is the URL where uploaded files will be accessible.

Example: /uploads or https://mydomain.test/uploads

mime_types (array, default: [])

This is an array of allowed MIME types. An empty array means that all MIME types are allowed.

Examples:

disable_compression (boolean, default: false)

This allows you to disable compression in order to avoid the small overhead that it produces after resizing.

compress_only_original (boolean, default: false)

This will compress only the original image and will ignore thumbnails. This can be a good option as the thumbnails are already quite small, and sometimes it may not be necessary to compress them.

max_file_size (integer, default: 7340032)

This is the maximum allowed file size in bytes. The default value is 7340032 (7 MB).

pagination_limit (integer, default: 30)

This is the number of items that will be shown per page in the Media File Manager. The default value is 30.

image

This is the configuration for the image settings.

resize_driver (enum, default: ImageResizeDriver::IMAGICK->value)

This is the driver that will be used for image resizing. The available drivers are:

resize_gif_driver (enum, default: GifResizeDriver::NONE->value)

This is the driver that will be used for GIF image resizing. The available drivers are:

quality (integer, default: 80)

This is the quality of the compression images. The default value is 80.

original_max_width (integer, default: 1920)

This is the maximum width for the original file. This will prevent the original file from being stored with a large number of megabytes. A null value will not resize the image.

breakpoints (array, default: ['large' => [1024], 'medium' => [768], 'small' => [576], 'xsmall' => [130, 130]])

This is an array of breakpoints that will be used to generate thumbnails with different sizes. The available breakpoints are:

Each breakpoint has its own default dimensions, but these can be overridden by specifying custom dimensions in the configuration.

Usage

Security

All routes in this bundle start with /ranky/media without any kind of security. But we all know that in Symfony it's very easy to protect a route with certain roles, like, for example:

With this configuration you have already secured the Media File Manager with the role ROLE_USER.

It is also possible as we have seen previously that you want to import the routes of this bundle with the prefix of /admin, then all you have to do is to put the prefix in the security path:

Don't forget to set the route prefix in the bundle configuration.

Media File Manager

Once installed, you can access a route that I have created for quick access to the Media File Manager. The path is /ranky/media/embed.

But the idea is that you create a page in your admin.

Example:

Form types

Only one type of form, but with 4 ways to store the data in the database:

1. Single selection. Store the mediaId (Ulid) without association

media_id type is a Doctrine ULID type

2. Multiple selection. Store the array of mediaId (json) without association

3. Single selection. Store path without association

4. Multiple selection. Store the array of paths without association

5. Single selection. Store the mediaId (Ulid) with ManyToOne association

6. Multiple selection. Store the media collection with ManyToMany association

Retrieve media files in Twig

To retrieve the media files, you have a global twig service will help you. Let's see the examples in the same order as we have looked in the types of forms.

Service: ranky_media RankyMediaTwigExtension

Extension:

Example

Responsive images with Twig macro

Standalone button to open the Media File Manager in selection mode

You can use the same options as in the form. Remember to import the assets first

The ranky-media-open-modal class is required, In order not to conflict with the form types.

TinyMCE integration

TinyMCE Ranky Media Bundle

The ranky-media-open-modal class is required.

EasyAdmin integration

A Form Types

Here, I show an example of the six variations:

Events

Caveats

Extra

Demo

In a few days there will be a complete demo. For now, you can watch the video

Install local certificates

More info https://github.com/FiloSottile/mkcert

Docker

You can see how to install PHP extensions and compression tools through Docker in the Dockerfile I used it for testing.

To Do

License

MediaBundle is licensed under the MIT License – see the LICENSE file for details

Donate


All versions of media-bundle with dependencies

PHP Build Version
Package Version
Requires ext-xml Version *
php Version >=8.1
symfony/framework-bundle Version ^5.4 || ^6.0 || ^7.0
symfony/translation Version ^5.4 || ^6.0 || ^7.0
symfony/validator Version ^5.4 || ^6.0 || ^7.0
symfony/mime Version ^5.4 || ^6.0 || ^7.0
symfony/form Version ^5.4 || ^6.0 || ^7.0
symfony/twig-bundle Version ^5.4 || ^6.0 || ^7.0
symfony/security-bundle Version ^5.4 || ^6.0 || ^7.0
symfony/webpack-encore-bundle Version ^1.16 || ^2.0
symfony/monolog-bundle Version ^3.8.0
symfony/uid Version ^5.4 || ^6.0 || ^7.0
doctrine/doctrine-bundle Version ^2.0
doctrine/orm Version ^2.6
spatie/image-optimizer Version ^1.1
intervention/image Version ^2.4
ranky/shared-bundle Version ^2.1
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 ranky/media-bundle contains the following files

Loading the files please wait ....