PHP code example of oscarweb / file-reporter

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

    

oscarweb / file-reporter example snippets



/* enter correct path */


/**
 * Set Directory
 * @param string
 */
$app = new FileReporter(__DIR__.DIRECTORY_SEPARATOR.'docs');

/**
 * Return data
 * @return object - default
 */
$response = $app->getReport();

var_dump($response);

/**
 * Set Cache Directory
 * @param string
 */
$app->setCacheDir(__DIR__.DIRECTORY_SEPARATOR.'cache');

/**
 * Return data
 * @return object - default
 */
$response = $app->getReport();


$app = new FileReporter();

/**
 * @return object - default
 */
$control = $app->getControl();

/**
 * Set Directory
 * @param string
 */
$app = new FileReporter(__DIR__.DIRECTORY_SEPARATOR.'docs');

/**
 * Set Cache Directory
 * @param string
 */
$app->setCacheDir(__DIR__.DIRECTORY_SEPARATOR.'cache');

/**
 * Adjust the output of the json file: JSON_PRETTY_PRINT
 */
$app->setJsonPrettyPrint();

/**
 * Your custom function
 */
function recursive($route, $app){
	$app->setDir($route);
	$result = $app->getReport();

	foreach($result->content as $item){
		if($item->is->dir){
			recursive($item->data->route, $app);
		}
	}
}

recursive($app->getDir(), $app);


$app = new FileReporter(__DIR__.DIRECTORY_SEPARATOR.'docs');

/**
 * If you set cache, it will filter on all reports.
 */
$app->setCacheDir(__DIR__.DIRECTORY_SEPARATOR.'cache');

/**
 * HASH Files - sha1
 * @return object - default
 */
$duplicate_files = $app->filterCache()->repeatsByHash();