1. Go to this page and download the library: Download infocyph/pathwise 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/ */
use Infocyph\Pathwise\StreamHandler\MalwareScanMode;
use Infocyph\Pathwise\StreamHandler\UploadProcessor;
use Infocyph\Pathwise\StreamHandler\UploadSource;
use Infocyph\Pathwise\StreamHandler\UploadTrustProfile;
$uploader = new UploadProcessor();
$uploader->setStorageContext($storage);
$uploader->setTrustProfile(UploadTrustProfile::UNTRUSTED_DATA);
$uploader->setDirectorySettings('primary://uploads', tempDir: sys_get_temp_dir());
$uploader->setValidationProfile('document');
$uploader->setMalwareScanMode(MalwareScanMode::REQUIRED);
$uploader->setMalwareScanner($scanner);
$source = UploadSource::fromMover(
mover: static function (string $target) use ($uploadedFile): void {
$uploadedFile->moveTo($target);
},
clientFilename: $uploadedFile->getClientFilename() ?? 'upload.bin',
size: $uploadedFile->getSize(),
clientMediaType: $uploadedFile->getClientMediaType(),
error: $uploadedFile->getError(),
);
$path = $uploader->ingestSource($source);
use Infocyph\Pathwise\StreamHandler\PublicFileResolver;
$asset = (new PublicFileResolver())->resolve(
'/srv/app/public',
'assets/app.css',
);
// $asset->path is canonically contained and can now feed DownloadProcessor
// or an already-authorized response/file writer.
use Infocyph\Pathwise\StreamHandler\DownloadProcessor;
$downloads = new DownloadProcessor();
$downloads->setStorageContext($storage);
$downloads->setAllowedRoots(['primary://downloads']);
$prepared = $downloads->prepareDownload(
'primary://downloads/video.mp4',
rangeHeader: $_SERVER['HTTP_RANGE'] ?? null,
);
foreach ($downloads->streamChunks($prepared) as $chunk) {
echo $chunk;
}
use Infocyph\Pathwise\Queue\FileJobQueue;
$queue = new FileJobQueue('/var/lib/app/jobs.json');
$queue->enqueue('thumbnail', ['id' => 'asset-42']);
$reservation = $queue->reserve();
if ($reservation !== null) {
// Work with $reservation->payload, renew long jobs when
use Infocyph\Pathwise\Integration\Runwire\RunwireExecutionContext;
use Infocyph\Pathwise\StreamHandler\DownloadProcessor;
// $runtime and $request are supplied by the active host; Pathwise does not create them.
$execution = new RunwireExecutionContext($runtime, $request, $scope ?? null);
$download = new DownloadProcessor();
$result = $download->withRunwire(
$execution,
static fn (DownloadProcessor $bound) => $bound->prepareDownload($path),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.