Download the PHP package setono/sylius-video-plugin without Composer

On this page you can find all versions of the php package setono/sylius-video-plugin. 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 sylius-video-plugin

Sylius Video Plugin

Latest Version Build Status Code Coverage

Adds a Videos tab to the admin product create/edit page so editors can attach videos to a product through three built-in types — file upload, external URL and direct embed code — and renders them on the shop product page.

An optional fourth type, Cloudflare Stream, uploads videos from the admin's browser straight to Cloudflare Stream and plays them on the product page through Cloudflare's own player, or a player of your choice — see Cloudflare Stream.

Videos are stored with Single Table Inheritance (a base ProductVideo plus FileProductVideo / UrlProductVideo / EmbedProductVideo subtypes) and presented through tagged composite renderers, so the plugin is extended exactly like setono/sylius-qr-code-plugin: add a subtype + a resource entry + a renderer and the discriminator map picks it up — no edits to the plugin's mapping required.

Installation

Requirements

1. Require the plugin

2. Register the bundle

3. Make your Product own its videos

Implement ProductVideosAwareInterface and use the trait on your Product:

That is all for an attribute-mapped Product (the Sylius-Standard default): the trait's videos property carries the OneToMany attributes (mapped by product, cascade persist, orphan removal, ordered by position), and Doctrine reads them through your class. The owning ManyToOne lives on ProductVideo. The test application under tests/Application does exactly this.

If your Product is XML- or YAML-mapped instead, the attributes are ignored and you declare the inverse side yourself, next to the rest of your mapping:

Either way, point the product resource at your class (skip if you already override it):

4. Update the database

The plugin does not ship migrations — generate one against your own schema and run it:

This creates the single setono_sylius_video__product_video table. The discriminator listener adds the Single Table Inheritance map at runtime (keyed on each subtype's getType()), so no extra mapping is needed beyond the videos association you added in step 3. The type column is 64 characters wide so derived type names of custom subtypes fit; installs created with an earlier development version (20 characters) pick the change up with another doctrine:migrations:diff.

5. Install assets

This publishes the small dependency-free JavaScript controller that toggles the type-specific field on the adaptive entry form to match the selected type, and the shop stylesheet that keeps the video block responsive (it stretches pasted embed iframes to the 16:9 box). The stylesheet is added to the shop layout through the sylius.shop.layout.stylesheets event; override or disable that setono_sylius_video block if your theme ships its own styles.

Upload limits

Video files go through the same Sylius media filesystem as product images. That adapter is string-based, so each upload passes through PHP memory once, and the request must fit the upload_max_filesize, post_max_size and memory_limit of the PHP that serves the admin. Size those for the largest video you expect (a few hundred megabytes is a practical ceiling), and prefer attaching very large videos as an External URL video hosted elsewhere.

Uploads are validated in the sylius group by the plugin's validation XML: a video file must sniff as video/mp4, video/webm, video/ogg or video/quicktime, and a poster must be a JPEG, PNG or WebP image of at most 10 MB. To tighten either (a lower video size cap, fewer types), add your own constraints for Setono\SyliusVideoPlugin\Model\FileProductVideo or ProductVideo in config/validator/; Symfony merges them with the plugin's.

Usage

Configuration

Cloudflare Stream

An opt-in type for shops that host their videos on Cloudflare Stream. The file never passes through the shop's PHP: the admin form uploads it from the browser straight to Cloudflare (a direct creator upload over the tus protocol, in 50 MiB chunks, so PHP upload limits do not apply) and only the video's uid is saved. On the product page the video plays through Cloudflare's own Stream Player (an iframe, no JavaScript dependency), with Cloudflare's generated thumbnail as the poster unless one was uploaded; a template override can plug in any other player.

Setup

  1. In the Cloudflare dashboard note the account id, create an API token with the Stream: Edit permission, and copy the customer subdomain shown under Stream (customer-<code>.cloudflarestream.com; the code alone is accepted too).
  2. Enable the type:

  3. Import the plugin's admin route (the endpoint that creates uploads) and Symfony's webhook endpoint, which the symfony/webhook Flex recipe adds as config/routes/webhook.yaml:

  4. Add the columns and publish the shop script: bin/console doctrine:migrations:diff (two nullable columns on the video table, cloudflare_stream_uid and cloudflare_stream_ready), doctrine:migrations:migrate and assets:install.

  5. Point Cloudflare's webhook at the shop:

    The URL defaults to the application's /webhook/cloudflare_stream endpoint with the host from framework.router.default_uri; pass another URL as the argument to override it. The command is idempotent (a subscription that already points at the URL is left alone; --force subscribes again), so it can simply run on every deploy.

    There is no secret to copy around: Cloudflare returns the signing secret together with the subscription, and the plugin reads it back through the API. It is remembered in cache.app for an hour and read again when a signature stops matching, so re-subscribing needs no restart. Set webhook_secret only if you want to pin the secret in the configuration instead.

    Cloudflare allows one webhook per account. If several environments share an account, only the one subscribed last is notified, so run the command for production only and let the others rely on the sync command below.

How it behaves

Security

The embed type stores the HTML an administrator pastes and prints it on the product page with |raw, on purpose: provider embed codes need their <iframe> and attributes intact, and a sanitizer would break them. Treat that field as trusted input. Anyone who can edit a product can put arbitrary markup and scripts in front of every visitor of that product page, and Sylius has no admin role finer than "can edit products".

Overriding

Extending — adding a new video type

Worked example: a youtube type that extends the URL type to reuse its url column and accessors, parses the video id from the link, renders YouTube's player and computes its thumbnail from the YouTube CDN. Because it adds no column no migration is needed. The test application ships this exact type under tests/Application (Entity/Video, Form, Renderer, Poster, config/validator, templates/video, translations), so read it as a complete reference.

Step Artefact Wired by
1 <Type>ProductVideo model (+ interface) class name → getType()
2 ORM mapping (mapped superclass, fields only for new columns) Doctrine mapping config
3 Sylius resource entry sylius_resource.resources.<app>.<name>
4 Renderer (+ template) and optional poster resolver tags setono_sylius_video.renderer / .poster_resolver
5 Form fields a ProductVideoType extension, tag form.type_extension
6 Validation XML in group sylius, setono_sylius_video.ui.types.<type> label Symfony validator / translations

1. Subtype model + interface — name it <Type>ProductVideo and the static getType() derives the discriminator (YoutubeProductVideo → youtube); override it only for a non-conventional name. Extending a concrete type is fine: the derived name (youtube, not url) keeps the two apart in the discriminator map. Two models resolving to the same type (for example an override of getType() returning url) fail loudly at container build and metadata load, since one would otherwise shadow the other in the map; to replace a built-in type's class rather than add a type, override its resources.*.classes.model instead (see Configuration).

2. ORM mapping — every class in the discriminator map must be known to a mapping driver, even one that adds no column, so always ship a mapping. Declare it as a mapped superclass (Sylius turns the resource into an entity) and map fields only for new columns. With attributes that is a single line on the class:

or, for an XML-mapped entity namespace, <mapped-superclass name="App\Entity\Video\YoutubeProductVideo"/> in config/doctrine/Video.YoutubeProductVideo.orm.xml.

3. Register it as a resource — the plugin scans every Sylius resource whose model implements ProductVideoInterface: the discriminator listener adds it to the STI map and the type selector picks it up (label derived as setono_sylius_video.ui.types.<type>). No plugin config to edit, no listener to decorate:

4. Renderer + poster — implement VideoRendererInterface (instanceof YoutubeProductVideoInterface), tag it setono_sylius_video.renderer with a priority above 0 so it is asked before the plugin's URL renderer (a YouTube video is a URL video too, and the composite picks the first renderer that supports it), and add a template for it. Add a poster resolver that builds the thumbnail from the parsed id and tag it setono_sylius_video.poster_resolver; the plugin's stored-poster resolver runs at priority 100, so an uploaded poster still wins:

5. Form fields — ship a ProductVideoType extension for the type's input(s) by extending AbstractProductVideoTypeExtension and tagging it form.type_extension. Declare the type and its field(s) as a name => [form type, options] map; the base class adds them, reveals/hides them per the selected type and strips them on submit when another type is chosen:

6. Validation + translations — add a per-subtype validation file with its constraints in the sylius group (each row is validated in %setono_sylius_video.form.type.product_video.validation_groups%, [sylius] by default) and the setono_sylius_video.ui.types.youtube label key (plus labels for any fields your extension adds).

Development & quality gates

CI (.github/workflows/build.yaml) enforces more than the composer scripts: vendor/bin/rector process --dry-run, vendor/bin/infection (minCoveredMsi 100, minMsi ratcheted in infection.json.dist), vendor/bin/composer-dependency-analyser, composer validate --strict, composer normalize --dry-run, and lint:yaml, lint:twig and lint:container in the test application. Run them before pushing.

The test application lives in tests/Application. Admin credentials: sylius / sylius.

License

This plugin is released under the MIT License. See the bundled LICENSE file.


All versions of sylius-video-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
doctrine/collections Version ^1.8 || ^2.0
doctrine/orm Version ^2.15 || ^3.0
doctrine/persistence Version ^2.0 || ^3.0
psr/clock Version ^1.0
psr/log Version ^1.1 || ^2.0 || ^3.0
setono/composite-compiler-pass Version ^1.3
setono/doctrine-orm-trait Version ^1.4
sylius/admin-bundle Version ^1.13
sylius/core Version ^1.13
sylius/core-bundle Version ^1.13
sylius/product-bundle Version ^1.13
sylius/resource-bundle Version ^1.11
symfony/cache-contracts Version ^2.5 || ^3.0
symfony/config Version ^6.4
symfony/console Version ^6.4
symfony/dependency-injection Version ^6.4
symfony/event-dispatcher Version ^6.4
symfony/form Version ^6.4
symfony/http-client Version ^6.4
symfony/http-client-contracts Version ^3.0
symfony/http-foundation Version ^6.4
symfony/options-resolver Version ^6.4
symfony/remote-event Version ^6.4
symfony/routing Version ^6.4
symfony/translation-contracts Version ^2.5 || ^3.0
symfony/validator Version ^6.4
symfony/webhook Version ^6.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 setono/sylius-video-plugin contains the following files

Loading the files please wait ...