PHP code example of duyld2108 / laravel-file-manager

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

    

duyld2108 / laravel-file-manager example snippets


'image_optimization' => [
    // Enable or disable auto optimization on upload
    'enabled'                   => true,

    // Target format: 'webp', 'avif', 'jpg', 'png', or null (keep original format)
    'format'                    => 'webp',

    // Quality for lossy formats (1 - 100)
    'quality'                   => 85,

    // Maximum dimensions in pixels (proportional scaleDown)
    'max_width'                 => 2048,
    'max_height'                => 2048,

    // Keep original file if the converted version is larger
    'keep_original_when_larger' => true,

    // Supported raster mimetypes
    'mimetypes'                 => [
        'image/jpeg',
        'image/pjpeg',
        'image/png',
        'image/webp',
        'image/bmp',
    ],
],

'thumbnails' => [
    // Cache thumbnails on disk to avoid repeating on-the-fly image operations
    'cache_on_disk' => true,

    // Hidden directory name for cached thumbnails
    'thumb_folder'  => '.thumbs',

    // Thumbnail dimensions (pixels)
    'width'         => 120,
    'height'        => 120,
],

'security' => [
    // Validate actual MIME types via PHP fileinfo
    'validate_mime'         => true,

    // Disallowed extensions (case-insensitive)
    'disallowed_extensions' => [
        'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar',
        'html', 'htm', 'shtml', 'dhtml', 'xhtml',
        'exe', 'sh', 'bash', 'bat', 'cmd', 'ps1', 'cgi', 'pl', 'py', 'rb',
        'js', 'vbs', 'jar', 'apk', 'msi', 'htaccess', 'htpasswd', 'env'
    ],

    // Disallowed MIME types
    'disallowed_mimetypes'  => [
        'text/x-php',
        'application/x-httpd-php',
        'application/x-php',
        'text/html',
        'application/xhtml+xml',
        'application/x-executable',
        'application/x-msdownload',
        'application/x-sh',
        'application/javascript',
        'text/javascript',
    ],
],

// Route prefix (default: /file-manager)
'routePrefix' => 'file-manager',

// Disk names from config/filesystems.php accessible in file manager
'diskList' => ['public'],

// Window layout: 1 = Single window, 2 = Window with directory tree, 3 = Two windows
'windowsConfig' => 2,

// Middleware applied to file manager routes
'middleware' => ['web', 'auth'],

use Duyld2108\LaravelFileManager\Services\ConfigService\DefaultConfigRepository;
use Duyld2108\LaravelFileManager\Services\ACLService\ConfigACLRepository;
bash
php artisan vendor:publish --tag=fm-config
bash
php artisan vendor:publish --tag=fm-assets
bash
php artisan storage:link
bash
php artisan vendor:publish --tag=file-manager-config --force