anfallnorr / file-manager-system
A Symfony bundle for file management (move, copy, delete, resize, etc.).
Installs: 51
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/anfallnorr/file-manager-system
Requires
- php: >=8.3
- symfony/asset: ^7.2
- symfony/flex: ^2.4.7
- symfony/form: ^7.2
- symfony/framework-bundle: ^7.2
- symfony/http-foundation: ^7.2
- symfony/mime: ^7.2
- symfony/string: ^7.2
- symfony/translation: ^7.2
- symfony/twig-bundle: ^7.2
- symfony/validator: ^7.2
README
FileManagerSystem is a Symfony bundle that provides easy and intuitive management of files and directories: creation, deletion, moving, MIME type handling, image resizing, and more.
It is designed to simplify file management within any Symfony application.
🚀 Installation
Install the bundle via Composer:
composer require anfallnorr/file-manager-system
⚙️ Configuration
1. Register the Bundle
Add the bundle to your config/bundles.php file:
return [ // ... Anfallnorr\FileManagerSystem\FileManagerSystem::class => ['all' => true], ];
2. AssetMapper Configuration (Optional)
If you want to use the built-in controller and assets provided by the bundle, create the following configuration files.
Create config/packages/file_manager_system.yaml
framework: asset_mapper: paths: - '%kernel.project_dir%/vendor/anfallnorr/file-manager-system/assets'
Create config/routes/file_manager_system.yaml
file_manager_system: resource: '../../vendor/anfallnorr/file-manager-system/src/Controller/' type: attribute prefix: /files-manager
💡 Usage
Injecting the Service
public function __construct( private FileManagerService $fmService ) { $this->fmService ->setDefaultDirectory('/var/uploads') ->setRelativeDirectory('/var/uploads'); }
$fmService = $this->fmService;
📚 Examples
Get the default upload directory
$defaultDirectory = $fmService->getDefaultDirectory(); // e.g. /path/to/project/public/uploads
Change the default upload directory
$directory = $fmService ->setDefaultDirectory(directory: '/var/www/uploads') ->getDefaultDirectory(); // e.g. /path/to/project/var/www/uploads
Retrieve all available MIME types
$mimeTypes = $fmService->getMimeTypes(); // returns an array
Get the MIME type for a specific extension
$mimeType = $fmService->getMimeType(key: 'pdf'); // application/pdf
Create a URL-friendly slug
$slug = $fmService->createSlug(string: 'Hello World !'); // hello-world
Create a directory
$fmService->createDir(directory: 'Hello World !', return: false);
If return is set to true, the method returns:
[
'absolute' => "/absolute/path/hello-world",
'relative' => $relative,
'ltrimmed_relative' => \ltrim($relative, '/'),
'foldername' => $dir
]
Create a file with optional content
$fmService->createFile( filename: 'Hello World.html', content: 'Hello World! I\'m Js Info' );
🧩 Optional (Twig Integration)
If you are using Twig and want Bootstrap-styled forms, add this in:
config/packages/twig.yaml
twig: form_themes: ['bootstrap_5_layout.html.twig']