Skip to content

sotechn/php-m3u8

 
 

Repository files navigation

PHP M3u8

v1.2.0

M3u8 file parser / dumper

SensioLabsInsight

Latest Stable Version License Build Status Scrutinizer Code Quality Code Coverage StyleCI

Installation

$ composer require 'chrisyue/php-m3u8'

Usage

parser

$parser = new \Chrisyue\PhpM3u8\Parser();
$m3u8 = $parser->parse($m3u8Content);

// or with loader
class MyLoader implements LoaderInterface
{
    public function load($uri)
    {
        // return $uri content by `file_get_contents` or `guzzle` etc.
    }
}

$parser->setLoader(new MyLoader());
$parser->parseFromUri($uri);

Fortunately you don't really need to write a MyLoader class because there is already a CachableLoader along with this library

supposing you are using psr6 compatible cache utils like Symfony cache component:

$cachePool = new \Symfony\Component\Cache\Adapter\ApcuAdapter();
$loader = new \Chrisyue\PhpM3u8\CachableLoader($cachePool);

$parser->setLoader($loader);
$m3u8 = $parser->parseFromUri($uri);

dumper

$dumper = new \Chrisyue\PhpM3u8\Dumper();
echo $dumper->dump($m3u8);

About

PHP M3u8 parser / dumper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%