Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

PHP library for dealing with data URLs
https://github.com/neoncitylights/php-data-url

data-url php rfc-2397

Last synced: 2 days ago
JSON representation

PHP library for dealing with data URLs

Awesome Lists containing this project

README

        

# DataUrl
![Packagist Version](https://img.shields.io/packagist/v/neoncitylights/data-url)
![GitHub](https://img.shields.io/github/license/neoncitylights/php-data-url)
[![PHP Composer](https://github.com/neoncitylights/php-data-url/actions/workflows/php.yml/badge.svg)](https://github.com/neoncitylights/php-data-url/actions/workflows/php.yml)
[![codecov](https://codecov.io/gh/neoncitylights/php-data-url/branch/main/graph/badge.svg?token=IdWjeqFQcS)](https://codecov.io/gh/neoncitylights/php-data-url)

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 2397[^rfc-2397].

## Install
```
composer require neoncitylights/data-url
```

## Usage
```php
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](/LICENSE).

[^rfc-2397]: Masinter, L., & X. (1998, August). The "data" URL scheme. Retrieved October 30, 2020, from