PHPackages                             ride/lib-media - 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. ride/lib-media

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

ride/lib-media
==============

Library for abstraction of media services in the Ride framework

1.0.4(6y ago)05.2k3MITPHP

Since May 22Pushed 6y ago8 watchersCompare

[ Source](https://github.com/all-ride/ride-lib-media)[ Packagist](https://packagist.org/packages/ride/lib-media)[ RSS](/packages/ride-lib-media/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (17)Used By (3)

ride/lib-media
==============

[](#ridelib-media)

This library adds support for custom media items, like Youtube videos, Soundcloud music or plain URL's.

MediaItem classes live in the `item/` directory, and their factories in the `factory` directory.

What's In This Library
----------------------

[](#whats-in-this-library)

### MediaItemFactory

[](#mediaitemfactory)

The *MediaItemFactory* class is the interface for all media item factories. This factory has two responsibilities:

- check a given URL if it is valid for the assosiated MediaItem class
- instantiate a new MediaItem class

The `AbstractMediaItemFactory` has a default implementation for the `createFormUrl`, `createFromId` and `setClientId` methods. Its constructor requires an instance of `ride\library\http\client\Client`.

The `isValidUrl` method should always be implemented in the child class, and should contain logic in order to determine if an URL is parseable for the related media item.

### MediaItem

[](#mediaitem)

The *MediaItem* class is the interface for all media items. There is an abstract implementation called `AbstractMediaItem` from which all classes can extend. Each *MediaItem* class should implement at least following methods:

```
abstract protected function parseUrl($url);
abstract protected function loadProperties();
```

The `parseUrl` method will take a given URL and parse it for this specific *MediaItem* implementation. It can be assumed that this URL is parseable because of the check done in the *MediaItemFactory*.

Each media item needs a factory for the *MediaFactory* to be able to use it.

### MediaFactory

[](#mediafactory)

The *MediaFactory* interface glues all the *MediaItemFactory* instances together into an easy facade. It will use specific media item factories to test if a given URL can be parsed.

A generic implementation is provided through the *SimpleMediaFactory* class.

Code sample
-----------

[](#code-sample)

You can check the following code sample to see some of the possibilities of this library:

```
use ride\library\media\factory\UrlMediaItemFactory;
use ride\library\media\factory\VimeoMediaItemFactory;
use ride\library\media\factory\YoutubeMediaItemFactory;
use ride\library\media\MediaFactory;
use ride\library\media\SimpleMediaFactory;
use ride\library\http\client\Client;

function createMediaFactory(Client $httpClient) {
    $youtubeMediaItemFactory = new YoutubeMediaItemFactory($httpClient);
    $youtubeMediaItemFactory->setClientId('client-id');

    $vimeoMediaItemFactory = new VimeoMediaItemFactory($httpClient);

    $urlMediaItemFactory = new UrlMediaItemFactory($httpClient);

    $mediaFactory = new SimpleMediaFactory($httpClient);
    $mediaFactory->setMediaItemFactory($youtubeMediaItemFactory);
    $mediaFactory->setMediaItemFactory($vimeoMediaItemFactory);
    $mediaFactory->setDefaultMediaItemFactory($urlMediaItemFactory);

    return $mediaFactory;
}

function useMediaFactory(MediaFactory $mediaFactory) {
    // create a MediaItem using a URL
    $youtubeMediaItem = $simpleMediaFactory->createMediaItem('https://www.youtube.com/watch?v=njos57IJf-0');

    $type = $youtubeMediaItem->getType();
    // youtube
    $id = $youtubeMediaItem->getId();
    // njos57IJf-0
    $title = $youtubeMediaItem->getTitle();
    $description = $youtubeMediaItem->getDescription();

    // if you know the type and id, you can fetch it like this
    $youtubeMediaItem = $simpleMediaFactory->getMediaItem($type, $id);
}
```

Related Modules
---------------

[](#related-modules)

- [ride/app-media](https://github.com/all-ride/ride-app-media)
- [ride/lib-http-client](https://github.com/all-ride/ride-lib-http-client)
- [ride/lib-validation](https://github.com/all-ride/ride-lib-validation)

Installation
------------

[](#installation)

You can use [Composer](http://getcomposer.org) to install this library.

```
composer require ride/lib-media

```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 61.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~140 days

Recently: every ~271 days

Total

15

Last Release

2419d ago

Major Versions

0.5.2 → 1.0.02016-10-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d98d3f0d5db5eb241c6ee74bcee87d1e7dc1aaf7942b933d68e612ee2352eea?d=identicon)[ride-user](/maintainers/ride-user)

---

Top Contributors

[![kayalion](https://avatars.githubusercontent.com/u/2340819?v=4)](https://github.com/kayalion "kayalion (39 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (16 commits)")[![kristofser](https://avatars.githubusercontent.com/u/5928907?v=4)](https://github.com/kristofser "kristofser (8 commits)")

### Embed Badge

![Health badge](/badges/ride-lib-media/health.svg)

```
[![Health](https://phpackages.com/badges/ride-lib-media/health.svg)](https://phpackages.com/packages/ride-lib-media)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
