diff --git a/examples/example.php b/examples/example.php index c66017a..a6090d4 100644 --- a/examples/example.php +++ b/examples/example.php @@ -77,4 +77,4 @@ ); // Export document to file. -$document->export2File(__DIR__ . '/example.MD'); +$document->export2File(__DIR__ . '/generated/example.MD'); diff --git a/examples/example.MD b/examples/generated/example.MD similarity index 100% rename from examples/example.MD rename to examples/generated/example.MD diff --git a/src/MDGenerator/ExporterTrait.php b/src/MDGenerator/ExporterTrait.php index e312798..9d5837e 100644 --- a/src/MDGenerator/ExporterTrait.php +++ b/src/MDGenerator/ExporterTrait.php @@ -41,6 +41,11 @@ public function export2File(string $path): void $content = $this->_documentContent; try { + $directory = dirname($path); + if (!file_exists($directory)) { + mkdir($directory, 0755, true); + } + file_put_contents($path, $content); } catch (Exception $e) {