PHPackages                             knplabs/media-exposer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. knplabs/media-exposer

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

knplabs/media-exposer
=====================

A media path/source resolution library in PHP

1428.1k3PHP

Since Apr 24Pushed 13y ago8 watchersCompare

[ Source](https://github.com/KnpLabs/MediaExposer)[ Packagist](https://packagist.org/packages/knplabs/media-exposer)[ RSS](/packages/knplabs-media-exposer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Media Exposer
=============

[](#media-exposer)

The **Media Exposer** is a PHP (5.3+) library that helps you expose your media files to the clients of your web application.

Principle
---------

[](#principle)

When you develop a web application, you always need to set up a strategy to serve your medias to the clients. This is the problem this library tries to help you solve.

The **Exposer** is the main entry point of the library. It is responsible for returning the right source or the right path for the given media and options. To do that, it iterates over the registered resolvers to find the first one supporting the given media and options. The source or path generation is delegated to it. So the first thing to do when you want to set up an exposer is to register resolvers. When you register a resolver, you give it a priority.

All resolvers implement the *Resolver* interface. They indicate if they support a given media and options. But this only interface is not sufficient so a proper resolver must also implement either the *SourceResolver* interface or the *PathResolver* (or both).

Quick Exemple
-------------

[](#quick-exemple)

Enough discussion, let's try it.

As an exemple, will take the following simple image model:

```
