1. Go to this page and download the library: Download ssitu/barnett 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/ */
ssitu / barnett example snippets
use SSITU\Barnett\Barnett; # Barnett also has an Assistant.
# optional:
$Barnett->setLogger($somePsr3Logger);
# alternatively, you can retrieve logs that way:
$Barnett->getLocalLogs();
// if no logger set: returns all logs history;
// else: only last entry
$zipLink = $Barnett->setZipSource('some/source/dir/path/', ['txt'])
->setZipLocation('some/zip/dir/path/')
->zip() # this won't work if no source / location specified
->shredZippedFiles(['ButNotThisOne.txt'])
->getDownloadLink('https://example.com/aliasPath/');
$Barnett->setZipSource($sourceDirPath,
$theseExtOnly = [],
$omitThesePaths = []);
$Barnett->setZipLocation($zipDirPath,
$zipFilename = null,
$addDate = true,
$overwrite = false);
$Barnett->zip();
$Barnett->shredZippedFiles($omitThesePaths = []),
$mockMode = false; # will only list files to delete
$Barnett->resetZipSource();
$Barnett->resetZipLocation();
$Barnett->resetZipLists(); # zippedFiles and shredResults
$Barnett->resetAll($localLogsToo = true);
$Barnett->isGreen(); # false if an error occured
$Barnett->getDownloadLink($aliasDirPath = null, # as said before, avoid null
$aliasFilename = null,
$text = 'download');
$Barnett->getZipLocation();
$Barnett->getZippedFilesList();
$Barnett->getShredList();
use SSITU\Barnett\Assistant;
# return appropriate ZipArchive flag
Assistant::archiveFlag($overwrite);
# attempt a recursive mkdir if need to
Assistant::affirmDirExistence($dirPath);
# remove zip extension from filename
Assistant::mayRemoveDotZip(&$filename);
# append zip extension to filename
Assistant::mayAppendDotZip(&$filename);
# append an integer to filename
Assistant::findUniqueName(&$zipName);
# append a timestamp to filename
Assistant::fileIsNow(&$zipName);
# cleanup slashes to avoid read/write failures
Assistant::reSlash(&$dirPath, $finalSlash = false);
# check if path is . or ..
Assistant::isDotSegment($path);
# handle extensions list: removes dot, set to lower case and jpeg becomes jpg
Assistant::normalizeExts(&$extensions);
# read a file's extension, set to lower case and jpeg becomes jpg
Assistant::extractNormalizedExt($path);
# resolve file object deletion
Assistant::shred($path);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.