PHPackages                             tuum/filemap - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. tuum/filemap

ActiveLibrary[File &amp; Storage](/categories/file-storage)

tuum/filemap
============

a file mapper for various file types.

1.0.0(9y ago)199[1 issues](https://github.com/TuumPHP/FileMap/issues)1MITPHP

Since Jan 31Pushed 8y ago1 watchersCompare

[ Source](https://github.com/TuumPHP/FileMap)[ Packagist](https://packagist.org/packages/tuum/filemap)[ RSS](/packages/tuum-filemap/feed)WikiDiscussions 1.x Synced today

READMEChangelogDependencies (3)Versions (16)Used By (1)

FileMap
=======

[](#filemap)

A file mapper that maps a path to various file types, such as images, text, and markdown file.

finds a file based on a given path, and returns the file resource or contents (string), associated mime-type, and other information.

### License

[](#license)

MIT License

### PSR

[](#psr)

PSR-1, PSR-2, and PSR-4.

Usage
-----

[](#usage)

```
$map = Tuum\Locator\FileMap::forge(
    __DIR__.'/map',   // root dir where mapped files exist.
    __DIR__.'/cache'  // give cache dir to convert md files.
);

// render the file based on path.
$found = $map->render('images/sample.jpg');
if (!$found->found()) {
    echo 'not found';
}
header('Content-Type: '.$found->getMimeType());
if ($fp = $found->getResource()) {
    fpassthru($fp);
} else {
    echo $found->getContents();
}
```

The `render` method will find a file, then returns an `FileInfo` object which has methods like:

### `FileInfo` Object

[](#fileinfo-object)

FileInfor have methods such as:

- `FileInfo::found(): bool`: returns if a file for a given path is found.
- `FileInfo::getMimeType(): string|null`: returns a mime types for the file.
- `FileInfo::getResource(): resource|null`: returns a resource for images, etc.
- `FileInfo::getContents(): string`: returns a contents of a text files. if a resource is given, this methods returns the content of the file resource.

depending on the type of file, the `FileInfo` object may have a file resource or a file's contents as string. Try retriving a file resource first, then file contents if no resource is found.

Emissions
---------

[](#emissions)

### Emitting based on Extensions

[](#emitting-based-on-extensions)

The FileMap will emit the file as a resource, if

- the path has an extension (i.e. `sample.jpg`), and
- the extension is defined in `$map->emit_extension`, and
- found the file at the path.

The following list some of the predefined extensions and associated mime-type:

```
    public $emit_extensions = [
        'pdf'  => 'application/pdf',
        'gif'  => 'image/gif',
    ];
```

To add your extensions,

```
$map->addEmitExtension('swf', 'application/x-shockwave-Flash');
```

### Viewing File Content

[](#viewing-file-content)

The FileMap will emit the file content as a text, if

- not handled by the emitting by extension, and
- a file exists with extensions defined in `$map->view_extensions`.

To add an extension for viewing files,

```
$map->addViewExtension('twig',
    function(FileInfo $found) use($twig) {
        $found->setContents($twig->render($found->getLocation()));
        return $found;
    },
    'text/html');
```

The following shows the pre-defined extensions and the behavior of rendering. In all cases, it returns mime-type as `text/html`.

- .php: evaluate the file as PHP.
- .txt, .text: get contents and put the string inside `` html tag.
- .md: converts the file to html using `MarkUp` object.

MarkUp for CommonMark
---------------------

[](#markup-for-commonmark)

`MarkUp` class converts common-mark (AKA Markdown) file to HTML. Construction Set markdown file root directory of markdown files, and cache directory,

Usage:

```
$markUp = Tuum\Locator\MarkUp::forge('/path/to/md', '/cache/dir');
$html = $markUp->getHtml('to/mark/down.md');
```

The `$markUp` will converts the CommonMark to HTML only when cached html file is not found.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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

Every ~43 days

Recently: every ~72 days

Total

14

Last Release

3594d ago

Major Versions

0.3.1 → 1.0.0beta12015-11-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ed783829e6fa0bd4b0def8c04ccfdfb2fc99f9e61e4a9470acad9e5abc5fcac?d=identicon)[asaokamei](/maintainers/asaokamei)

---

Top Contributors

[![asaokamei](https://avatars.githubusercontent.com/u/747030?v=4)](https://github.com/asaokamei "asaokamei (56 commits)")

### Embed Badge

![Health badge](/badges/tuum-filemap/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)

PHPackages © 2026

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