diff --git a/src/Object/Storable.php b/src/Object/Storable.php index 1bc911cc..0fcbb2c0 100644 --- a/src/Object/Storable.php +++ b/src/Object/Storable.php @@ -36,6 +36,9 @@ trait Storable public function setFilename($filename) { Assertion::string($filename, 'Invalid filename.'); + if (!is_dir(dirname($filename))) { + mkdir(dirname($filename), 0777, true); + } Assertion::directory(dirname($filename), 'The selected directory does not exist.'); Assertion::writeable(dirname($filename), 'The selected directory is not writable.'); $this->filename = $filename;