PHP code example of hphio / util

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

    

hphio / util example snippets


$shell = new ShellExec();
$cwd = sys_get_temp_dir();
$shell->exec("echo 'test' && echo 'error test' >&2", $cwd);

$tempdir = new Tempdir();
$path = $tempdir->create();

$tempfile = new Tempfile();
$path = $tempfile->create();

$container = new Container();
$container->add(ShellExec::class);
$container->add(VersionParser::class);
$container->add(GhostScript::class)->addArgument($container);

$ghostscript = $container->get(GhostScript::class);
$pathToPdfFile = '/path/to/file.pdf';
$outputfile = '/path/to/output.pdf';
$ghostscript->downgrade($pathToPdfFile, $outputfile);

$parser = new VersionParser();
$version = $parser->getVersion($pathToPdfFile);

$endTime = 1675209600;
$startTime = 1676470379;
$relativeTime = PeopleTime::calculate($endTime, $startTime);
echo $relativeTime; // "14 days"

$endTime = 2018748556;
$relativeTime = PeopleTime::calculate($endTime);
echo $relativeTime; // "11 years"
ini
post_max_size=8k
upload_max_filesize=7M

$manager = $container->get(IniUploadManager::class);  
echo $manager->getMaxUpload(); //7340032  
echo $manager->getMaxPost(); //8192  
echo $manager->getUploadLimit(); //8192  

$value = '8M';
$obj = ByteValueFactory::getByteInterpreter($container, $value);
$obj->getBytes($value); //8388608

$value = '8388608';
$obj = ByteValueFactory::getByteInterpreter($container, $value);
$obj->getBytes($value); //8388608