Download the PHP package braunstetter/media-bundle without Composer

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

License

This Bundle aims to make working with media entities easy.

It provides a general API for everything related to media objects without restricting your flexibility.

The BaseFile entity

A doctrine MappedSuperclass your files should always extend.

It provides everything basic you need to get the ball rolling.

Create file App\Entity\Image:

And migrate your database:

It doesn't look like much - but at this point, you're using an interface (FileInterface) your uploaders and forms can work with.
Furthermore, you just got a few basic methods and properties you can further manipulate and extend.

Important methods

These are methods you definitely should be familiar with.
Outer properties and methods of the BaseFile entity are documented inside the class itself.

getFullPath

This method puts together a folder and filename.
These properties both have to be set. Otherwise, this method returns null.

getType

The type of your file.
By default, it's the name of the file entity class in lowercase.
You should name your media entities with a media type in mind. E.g. Image or Document.

Connecting media entities

Once you have defined your media entities you can connect them to other entities. This would be a complete entity of a Page with some Images linked to it.

For simplicity, it's recommended to use ManyToMany relationships in every case. If you need to limit your images, you can do it via a Validation, and/or by using the max_items option of the MediaCollectionType.

FormTypes

The nice thing about this bundle is - it ships with FormTypes.

Full example

This is an example for a collection of editable Image entities:

This will give you a nice UI. This is a screenshot of a simple blanc form:

All screenshots (made automatically by panther) are available inside the folder: tests/tests/Functional/Ui/screenshots after you ran the testsuite.

choose_file is the translation string of the file-input button.
You can translate it by creating a translation file in the media namespace (e.g. media.fr.yaml) You can see all available translations in vendor/braunstetter/media-bundle/src/Resources/translations.

Available FormTypes

If you need more FormTypes, consider opening an issue or contributing by submitting a PR.

MediaCollectionType

This is the most important type. It inherits from the native Symfony\Component\Form\Extension\Core\Type\CollectionType and can hold a collection of media FormType's.

Options

max_items

The maximal items allowed for this collection. Defaults to 9999.

At the moment this option is used only by the javascript of this bundle. No PHP validation is triggered. If you want to limit your Collection - use a validator.

include_css

Determines whether the supplied CSS should be injected. Defaults to true.

If you want to style your collection in a custom way, you can disable the default CSS with this option.

ImageType

This FormType is dedicated to Images.

Options

All options for this FormType go into the entry_options options of MediaCollectionType:

data_class

If you decide to name your Image entity differently or put it into another namespace, you have to adjust also the data_class option.
This attribute is by default App\Entity\Media\Image.

placeholder_image_path

The public path to the placeholder image for this image field.
It's by default bundles/media/images/image-placeholder.jpg.

file_options

The array of options for the file field. A list of available options can be found // available options can be found here.
Defaults to an empty array.

Uploader

An uploader is just a class you can use:

You are working directly with your entity (not with a file or its path).
As long as your form has filled the file property with a file. The image will be uploaded. That's super easy and fun.

By default, the uploader will save the file to public/image/redactor/my-slugged-filename_2315g323.jpeg. Pay attention to the filename. It is getting slugged by default - and it is getting suffixed with an uniq id. You can disable the uniqFileName by passing false as a second argument.

Currently, this bundle ships with these uploaders:

Filesystem Uploader

Saves files to the local filesystem. Nothing special here at the moment.

Contributing

If you think this bundle could still be improved and expanded, then we welcome your PR.

Testing

To make sure everything works fine - you have to run the test suite.

You need to make sure Panther is working properly on your machine.
Then your tests should work fine performing a simple:

Roadmap

There are still some features that are definitely to come.

  1. [ ] Remove uploader (FlysystemBundle is the way to go.)
  2. [ ] Draggable UI (make media objects draggable)
  3. [ ] More FormTypes. (Document, PDF, Audio ...)

You are welcome to help to implement those features. If you have any suggestions on what's also missing - don't hesitate to open an issue.

Another good idea is to write a MediaLibraryBundle on top of this Bundle - using the symfony-ux ecosystem.


All versions of media-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/framework-bundle Version ^6.0
symfony/string Version ^6.0
webmozart/assert Version ^1.1
braunstetter/helper Version ^0
symfony/mime Version ^6.0
doctrine/orm Version ^2.11
symfony/form Version ^6.0
symfony/asset Version ^6.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 braunstetter/media-bundle contains the following files

Loading the files please wait ....