PHP code example of tuum / filemap

1. Go to this page and download the library: Download tuum/filemap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tuum / filemap example snippets


$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();
}

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

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

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

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