neoncitylights / php-data-url

PHP library for dealing with data URLs

Home Page:https://neoncitylights.github.io/php-data-url/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataUrl

Packagist Version GitHub PHP Composer codecov

A small PHP library for dealing with data URLs, which contain a media type and an encoded base64 string.

This library fully conforms to RFC 23971.

Install

composer require neoncitylights/data-url

Usage

<?php

use Neoncitylights\DataUrl\DataUrlParser;

$dataUrlParser = new DataUrlParser();
$dataUrl = $dataUrlParser->parse( 'data:text/plain;base64,VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==' );

print( $dataUrl->getMediaType()->getEssence() );
// 'text/plain'

print( $dataUrl->getData() );
// `VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==`

print( $dataUrl->getDecodedValue() );
// 'The five boxing wizards jump quickly.'

License

DataUrl is licensed under the MIT license.

Footnotes

  1. Masinter, L., & X. (1998, August). The "data" URL scheme. Retrieved October 30, 2020, from https://tools.ietf.org/html/rfc2397

About

PHP library for dealing with data URLs

https://neoncitylights.github.io/php-data-url/

License:MIT License


Languages

Language:PHP 94.0%Language:Dockerfile 6.0%