1. Go to this page and download the library: Download dxgx/tree-size-mailer 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/ */
dxgx / tree-size-mailer example snippets
return [
// Email recipients (array of email addresses)
'recipients' => [
env('TREE_SIZE_REPORT_EMAIL', '[email protected]'),
],
// Base directory to scan (defaults to Laravel base path)
'scan_path' => env('TREE_SIZE_REPORT_SCAN_PATH', base_path()),
// Maximum directory depth for overview and tree view
'max_depth' => (int) env('TREE_SIZE_REPORT_MAX_DEPTH', 5),
// Minimum size (bytes) for detailed report entries
'min_file_size' => (int) env('TREE_SIZE_REPORT_MIN_SIZE', 102400), // 100 KB
// Minimum size (bytes) for overview section
'min_overview_size' => (int) env('TREE_SIZE_REPORT_MIN_OVERVIEW_SIZE', 1048576), // 1 MB
// Minimum size (bytes) for tree view
'min_tree_size' => (int) env('TREE_SIZE_REPORT_MIN_TREE_SIZE', 1048576), // 1 MB
// Excluded directory patterns (supports wildcards)
'excluded_dirs' => [
// '/node_modules',
// '/vendor*',
// '*/cache',
// '*test*',
],
// Custom directory breakdowns with specific depth levels
'breakdown_dirs' => [
// '/vendor' => 3,
// '/storage/app/public/photos' => 2,
],
// Maximum rows in detailed report section (0 = unlimited)
'detailed_max_rows' => (int) env('TREE_SIZE_REPORT_DETAILED_MAX_ROWS', 100),
// Application name for email subject
'app_name' => env('APP_NAME', 'Laravel App'),
// Email layout sections (customize which sections to
// Show only overview and tree (minimal report)
'layout' => [
'root_level_overview',
'directory_tree',
],
// Show detailed report only
'layout' => [
'detailed_directory_sizes',
],
// Custom order (tree view first, then detailed)
'layout' => [
'directory_tree',
'detailed_directory_sizes',
'custom_breakdowns',
],
// All sections (default)
'layout' => [
'root_level_overview',
'directory_tree',
'detailed_directory_sizes',
'custom_breakdowns',
],
'excluded_dirs' => [
'/node_modules', // Exclude node_modules directory
'/vendor*', // Exclude vendor and any vendor_* directories
'*/cache', // Exclude any cache directory at any level
'*/storage/logs', // Exclude storage/logs directories
'*test*', // Exclude any directory with 'test' in the name
'*/dist', // Exclude build output directories
Custom Breakdowns**: Excluded patterns still apply within breakdowns
- **Tree View**: Excluded directory branches are completely omitted
### Custom Directory Breakdowns
Create dedicated sections for specific directories with custom depth levels. Directories in `breakdown_dirs` will:
- Have their own section in the email report
- Be excluded from the "Detailed Directory Sizes" section (to avoid duplication)
- Still appear in the tree view
- Have their sizes calculated and
'detailed_max_rows' => 100, // Limit to 100 rows (default)
'detailed_max_rows' => 0, // Show all rows (unlimited)
protected function schedule(Schedule $schedule)
{
$schedule->command('dg:tree-size-mailer')->daily();
}
// Daily at 2:00 AM
Schedule::command('dg:tree-size-mailer')->dailyAt('02:00');
// Weekly on Monday at 6:00 AM
Schedule::command('dg:tree-size-mailer')->weeklyOn(1, '06:00');
// Monthly on the 1st at 3:00 AM
Schedule::command('dg:tree-size-mailer')->monthlyOn(1, '03:00');
// Every Sunday at midnight
Schedule::command('dg:tree-size-mailer')->weekly()->sundays()->at('00:00');