PHPackages                             anfallnorr/file-manager-system - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. anfallnorr/file-manager-system

ActiveSymfony-bundle[File &amp; Storage](/categories/file-storage)

anfallnorr/file-manager-system
==============================

A Symfony bundle for file management (move, copy, delete, resize, etc.).

1.0.47(2mo ago)1122MITPHPPHP &gt;=8.4

Since Mar 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Anfallnorr/FileManagerSystem)[ Packagist](https://packagist.org/packages/anfallnorr/file-manager-system)[ Docs](https://github.com/Anfallnorr/FileManagerSystem)[ RSS](/packages/anfallnorr-file-manager-system/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (19)Versions (28)Used By (0)

FileManagerSystem
=================

[](#filemanagersystem)

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
--------------

[](#-installation)

Install the bundle via Composer:

```
composer require anfallnorr/file-manager-system
```

---

⚙️ Configuration
----------------

[](#️-configuration)

### 1. Register the Bundle

[](#1-register-the-bundle)

Add the bundle to your `config/bundles.php` file:

```
return [
    // ...
    Anfallnorr\FileManagerSystem\FileManagerSystem::class => ['all' => true],
];
```

### 2. AssetMapper Configuration (Optional)

[](#2-assetmapper-configuration-optional)

Warning

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
-------

[](#-usage)

### Service Injection

[](#service-injection)

Inject the `FileManagerService` into your controller or service:

```
public function __construct(
    private FileManagerService $fmService
) {
    $this->fmService->setDefaultDirectory('/var/uploads');
}
```

For convenience in examples below:

```
$fmService = $this->fmService;
```

---

📂 1. Directory Management
-------------------------

[](#-1-directory-management)

### 📌 Get the Default Upload Directory

[](#-get-the-default-upload-directory)

```
$defaultDirectory = $fmService->getDefaultDirectory();
// Returns: /path/to/project/public/uploads
```

### 📌 Set a New Default Upload Directory

[](#-set-a-new-default-upload-directory)

```
$directory = $fmService
    ->setDefaultDirectory('/var/uploads')
    ->getDefaultDirectory();
// Returns: /path/to/project/var/uploads
```

---

### 📁 1.1. Listing Directories

[](#-11-listing-directories)

The `getDirs()` method allows you to explore the file system with support for exclusions, depth control, and relative paths.

**Method Signature:**

```
getDirs(
    string $path = '/',
    string $excludeDir = '',
    string|array|null $depth = '== 0'
): array
```

**Parameters:**

- `$path` — Base directory path to search within
- `$excludeDir` — Directory name pattern to exclude from results
- `$depth` — Depth filter using comparison operators (`==`, `>`, `getDirs();
// Returns directories found at depth 0 in the default directory
```

**List directories inside a specific subfolder:**

```
$dirs = $fmService->getDirs(path: 'uploads');
// Returns all directories inside /uploads at depth 0
```

**Control search depth:**

```
$dirs = $fmService->getDirs(path: 'uploads', depth: '== 1');
// Returns only directories exactly 1 level below /uploads
```

**Exclude specific directories:**

```
$dirs = $fmService->getDirs(path: 'uploads', excludeDir: 'temp');
// Returns all directories except those containing "temp" in their path
```

**Combine all parameters:**

```
$dirs = $fmService->getDirs(path: 'uploads', excludeDir: 'temp', depth: '== 1');
// Returns directories at depth 1 under "uploads", excluding folders containing "temp"
```

---

### 📁 1.2. Creating Directories

[](#-12-creating-directories)

Create a new directory within the default directory.

**Method Signature:**

```
createDir(
    string $directory,
    bool $returnDetails = false
): array
```

**Parameters:**

- `$directory` — Directory name (will be slugified automatically)
- `$returnDetails` — If `true`, returns detailed path information

**Return Value:**

- `array` — Directory details (if `$returnDetails` is `true`)

#### Examples

[](#examples-1)

**Simple directory creation:**

```
$fmService->createDir(directory: 'Hello World!');
// Creates directory: /path/to/project/public/uploads/hello-world
```

**Get detailed information:**

```
$details = $fmService->createDir(directory: 'Hello World!', returnDetails: true);
// Returns:
// [
//     'absolute' => '/var/www/absolute/path/hello-world',
//     'relative' => '/path/hello-world',
//     'ltrimmed_relative' => 'path/hello-world',
//     'foldername' => 'hello-world'
// ]
```

---

📄 2. File Management
--------------------

[](#-2-file-management)

### 📄 2.1. Listing Files

[](#-21-listing-files)

The `getFiles()` method offers complete control over file search: depth, extension, folder filtering, and more.

**Method Signature:**

```
getFiles(
    string $path = '/',
    string|array|null $depth = '== 0',
    ?string $folder = null,
    ?string $ext = null
): array|bool
```

**Parameters:**

- `$path` — Base directory path to search within
- `$depth` — Depth filter using comparison operators (`==`, `>`, `getFiles();
// Returns files at depth 0 from the default directory, or false if none found
```

**Get files from a subfolder:**

```
$files = $fmService->getFiles(path: 'uploads');
// Returns files from /uploads at depth 0
```

**Limit search by depth:**

```
$files = $fmService->getFiles(path: 'uploads', depth: '== 1');
// Returns files located exactly 1 level below /uploads
```

**Filter by folder name:**

```
$files = $fmService->getFiles(path: 'uploads', folder: 'images');
// Returns only files within folders containing "images"
```

**Filter by file extension:**

```
$files = $fmService->getFiles(path: 'uploads', ext: 'jpg');
// Returns only .jpg files
```

**Combine all filters:**

```
$files = $fmService->getFiles(
    path: 'uploads',
    depth: '== 2',
    folder: 'products',
    ext: 'png'
);
// Returns .png files inside folders containing "products", at depth 2 under "uploads"
```

---

### 📄 2.2. Creating Files

[](#-22-creating-files)

Create a new file with optional content.

**Method Signature:**

```
createFile(
    string $filename,
    string $content = ''
): void
```

**Parameters:**

- `$filename` — File name (will be slugified automatically)
- `$content` — File content (defaults to basic HTML template)

**Return Value:**

- `void`

#### Examples

[](#examples-3)

**Create an HTML file with custom content:**

```
$fmService->createFile(
    filename: 'Hello World.html',
    content: 'Hello World! I\'m Js Info'
);
// Creates: /path/to/project/public/uploads/hello-world.html
```

**Create a file with default HTML template:**

```
$fmService->createFile(filename: 'welcome.html');
// Creates file with default HTML content
```

---

🔧 3. Utilities
--------------

[](#-3-utilities)

### 🧩 Retrieve All Available MIME Types

[](#-retrieve-all-available-mime-types)

Get a complete list of supported MIME types.

```
$mimeTypes = $fmService->getMimeTypes();
// Returns: ['pdf' => 'application/pdf', 'jpg' => 'image/jpeg', ...]
```

### 🧩 Get MIME Type for Specific Extension

[](#-get-mime-type-for-specific-extension)

Retrieve the MIME type for a given file extension.

```
$mimeType = $fmService->getMimeType(key: 'pdf');
// Returns: 'application/pdf'
```

### 🧩 Create URL-Friendly Slugs

[](#-create-url-friendly-slugs)

Convert any string into a URL-safe slug.

```
$slug = $fmService->createSlug('Hello World !');
// Returns: 'hello-world'
```

---

🎨 4. Optional: Twig Integration
-------------------------------

[](#-4-optional-twig-integration)

If you are using Twig and want Bootstrap-styled forms, add the following to your Twig configuration.

**Edit** `config/packages/twig.yaml`:

```
twig:
    form_themes: ['bootstrap_5_layout.html.twig']
```

---

📚 Additional Resources
----------------------

[](#-additional-resources)

- [Symfony Documentation](https://symfony.com/doc/current/index.html)
- [AssetMapper Component](https://symfony.com/doc/current/frontend/asset_mapper.html)

---

📝 License
---------

[](#-license)

This bundle is open-source and available under the MIT License.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance86

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~5 days

Total

27

Last Release

70d ago

PHP version history (2 changes)1.0.21PHP &gt;=8.3

1.0.28PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bafa2c99138754a92856c27109282317d6eb568b2d2d8da6c6381e667b5b2cc?d=identicon)[Anfallnorr](/maintainers/Anfallnorr)

---

Top Contributors

[![Anfallnorr](https://avatars.githubusercontent.com/u/90765278?v=4)](https://github.com/Anfallnorr "Anfallnorr (308 commits)")

---

Tags

copy-filescreate-directorycreate-filedelete-files-and-directoriesfilesystemmove-files-and-directoriesrename-files-and-directoriesresize-imagesupload-filesymfonyfilesystemfile managerSymfony Bundlefile systemfile-uploadfile deletefile-copyfile-move

### Embed Badge

![Health badge](/badges/anfallnorr-file-manager-system/health.svg)

```
[![Health](https://phpackages.com/badges/anfallnorr-file-manager-system/health.svg)](https://phpackages.com/packages/anfallnorr-file-manager-system)
```

###  Alternatives

[artgris/filemanager-bundle

FileManager is a simple Multilingual File Manager Bundle for Symfony

182420.8k9](/packages/artgris-filemanager-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
