function export($target, $setup = array())
{
    try {
        // lets stop the time
        $start = microtime(true);
        $filename = __DIR__ . '/data/sakila.mwb';
        $outDir = __DIR__ . '/result';
        $bootstrap = new \MwbExporter\Bootstrap();
        $formatter = $bootstrap->getFormatter($target);
        $formatter->setup($setup);
        $document = $bootstrap->export($formatter, $filename, $outDir, 'zip');
        // show the time needed to parse the mwb file
        $end = microtime(true);
        output($document, $end - $start);
        return $document;
    } catch (\Exception $e) {
        echo "<h2>Error:</h2>\n";
        echo "<textarea cols=\"100\" rows=\"5\">\n";
        echo $e->getMessage() . "\n";
        echo "</textarea>\n";
    }
}
function export($target, $setup = array(), $filename, $outDir)
{
    $html = "";
    try {
        // lets stop the time
        $start = microtime(true);
        $logFile = $outDir . '/log.txt';
        // créé dossier si existe pas
        if (!file_exists($outDir)) {
            try {
                $oldmask = umask(0);
                mkdir("{$outDir}", 0755);
                umask($oldmask);
            } catch (\Exception $e) {
                $html .= "<h2>Error:</h2>\n";
                $html .= "<textarea cols=\"100\" rows=\"5\">\n";
                $html .= $e->getMessage() . "\n";
                $html .= "</textarea>\n";
                return $html;
            }
        }
        $bootstrap = new \MwbExporter\Bootstrap();
        $formatter = $bootstrap->getFormatter($target);
        $formatter->setup(array_merge(array(\MwbExporter\Formatter\Formatter::CFG_LOG_FILE => $logFile), $setup));
        $document = $bootstrap->export($formatter, $filename, $outDir, 'file');
        // show the time needed to parse the mwb file
        $end = microtime(true);
        $html = output($document, $end - $start, $html);
        return $html;
    } catch (\Exception $e) {
        $html .= "<h2>Error:</h2>\n";
        $html .= "<textarea cols=\"100\" rows=\"5\">\n";
        $html .= $e->getMessage() . "\n";
        $html .= "</textarea>\n";
        return $html;
    }
}