PHPackages                             drewlabs/datauri - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. drewlabs/datauri

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

drewlabs/datauri
================

Classes and utilities for parsing/working with url encoded objects

v0.2.0(2y ago)0361MITPHPPHP &gt;=7.0

Since Dec 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/azandrew-sidoine/php-data-uri)[ Packagist](https://packagist.org/packages/drewlabs/datauri)[ RSS](/packages/drewlabs-datauri/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (1)

Library documentation
=====================

[](#library-documentation)

Data URI package provide an interface for working creating file from data uri string or converting files to data uri string. It provide an object that serves as bridge for converting from raw string or from files.

Usage
-----

[](#usage)

They data URI object provide method for creating object from file path or HTTP url

- Creating from path

```
// We assume file exists at path specified below
$path = __DIR__ . 'storage/file.txt';
$object = \Drewlabs\DataURI\DataURI::create($path);

// Converting $object to data uri string
$uri = $object->__toString();
// or using type casting
$uri = (string)$object;
```

- Creating from HTTP URL

```
$url = 'https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U';
$object = \Drewlabs\DataURI\DataURI::createFromURL($url);

// Converting $object to data uri string
$uri = $object->__toString();
// or using type casting
$uri = (string)$object;
```

- Creating from uri string

The package comes handy with a parser class for converting uri string to binary or text files that can be wrtten to storage.

```
$uri = 'data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,UEsDBBQABgAIAAAAIQCQyAt3kAEAADEHAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lUlrwzAQhe+F/geja4mV9FBKiZNDl2MbaAu9KtI4EdWGNNn...';

$parser = new \Drewlabs\DataURI\Parser();
$object = $parser->parse($uri); // Creates instance of \Drewlabs\DataURI\DataURI
```

API
---

[](#api)

- getContent()

Returns the internal binary content encoded in the {@see \\Drewlabs\\DataURI\\DataURI} object.

- getMimeType()

Returns the file mimeType. Currently commonly used web mime types are supported

- isBinary()

Returns true if the uri information is a binary content.

- getExtension()

Guess extension of the file using the mime type.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

931d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48c4973d500c7f4233d5ceacab51a57208d5fb60b0f95ae60264cf92380d0534?d=identicon)[azandrew-sidoine](/maintainers/azandrew-sidoine)

---

Top Contributors

[![azandrew-sidoine](https://avatars.githubusercontent.com/u/23530515?v=4)](https://github.com/azandrew-sidoine "azandrew-sidoine (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drewlabs-datauri/health.svg)

```
[![Health](https://phpackages.com/badges/drewlabs-datauri/health.svg)](https://phpackages.com/packages/drewlabs-datauri)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M45](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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