Download the PHP package tuum/filemap without Composer
On this page you can find all versions of the php package tuum/filemap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package 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
MIT License
PSR
PSR-1, PSR-2, and PSR-4.
Usage
The render
method will find a file, then returns an FileInfo
object which has methods like:
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
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:
To add your extensions,
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,
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
<pre>
html tag. - .md: converts the file to html using
MarkUp
object.
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:
The $markUp
will converts the CommonMark to HTML only when cached html file is not found.
All versions of filemap with dependencies
league/commonmark Version ^0.12
league/flysystem-cached-adapter Version ~1.0