Spatie\Backup\Tasks\Backup\TemporaryDirectory::path PHP Method

path() public method

public path ( string $fileName = '' ) : string
$fileName string
return string
    public function path(string $fileName = '') : string
    {
        if ($fileName === '') {
            return $this->path;
        }
        $fullPath = "{$this->path}/{$fileName}";
        if ($this->isProbablyADirectoryName($fileName)) {
            $this->createTemporaryDirectory($fullPath);
        }
        return $fullPath;
    }

Usage Example

Example #1
0
 protected function createZipContainingEveryFileInManifest(Manifest $manifest)
 {
     consoleOutput()->info("Zipping {$manifest->count()} files...");
     $pathToZip = $this->temporaryDirectory->path(config('laravel-backup.backup.destination.filename_prefix') . Carbon::now()->format('Y-m-d-H-i-s') . '.zip');
     $zip = Zip::createForManifest($manifest, $pathToZip);
     consoleOutput()->info("Created zip containing {$zip->count()} files. Size is {$zip->humanReadableSize()}");
     event(new BackupZipWasCreated($pathToZip));
     return $pathToZip;
 }