PHP code example of gidato / temporary-path

1. Go to this page and download the library: Download gidato/temporary-path 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/ */

    

gidato / temporary-path example snippets




use Gidato\TemporaryPath\Temporary;
use Gidato\Filesystem\Model\Base;

$base = new Base('/filesbase');
$temporary =  new Temporary($base->directory('tmp'));

// creates a TemporaryDirectory
$directory = $temporary->directory();
$directory->create();
$directory->drop();

// creates a TemporaryBasicFile
$file = $temporary->file();

// creates a TemporaryJsonFile
$file = $temporary->file('json');

// new file types - ConfigJsonFile extends JsonFile
$base->getFileTypesHandler()->addType('config.json', ConfigJsonFile::class);

// creates a TemporaryJsonFile as mapper not set up to convert ConfigJsonFile to anything else
$file = $temporary->file('config.json');

// now set up a mapper for ConfigJsonFile
$temporary->getFileClassMapper()->addType(ConfigJsonFile::class, TemporaryConfigJsonFile::class);

// now creates a TemporaryConfigJsonFile
$file = $temporary->file('config.json');