PHPackages                             karakum/yii2-path-registry - 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. karakum/yii2-path-registry

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

karakum/yii2-path-registry
==========================

This extension provides a directory generator for file storage based on the maximum occupancy directory.

0.4.0(9y ago)11262MITPHP

Since Jun 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/karakum/yii2-path-registry)[ Packagist](https://packagist.org/packages/karakum/yii2-path-registry)[ Docs](https://github.com/karakum/yii2-path-registry)[ RSS](/packages/karakum-yii2-path-registry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Path organizer Extension for Yii 2
==================================

[](#path-organizer-extension-for-yii-2)

This extension provides a directory generator for file storage based on the maximum occupancy directory.

Each time calling `getPath` method it search most empty directory. When all directories full filled according with max files count per directory(default 1000 files), extension generate new portion of directories(default 20 dirs). Using directory with each file must be marked by the method `countUpPath`. When file removed from directory the method `countDownPath` must be called.

Different filling setting can be using with several namespaces.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist karakum/yii2-path-registry "*"

```

or add

```
"karakum/yii2-path-registry": "*"

```

to the require section of your `composer.json` file.

Configure application component

```
    'components' => [
    ...
        'pathManager' => [
            'class' => 'karakum\PathRegistry\PathManager',
            'defaultMaxFiles' => 1000,
            'defaultNewFolders' => 20,
            'namespaces' => [
                'avatar' => [
                    'path' => '@webroot/uploads/avatar',
                    'url' => '@web/uploads/avatar',      // Direct download link
                    'maxFiles' => 100,
                    'newFolders' => 5
                ],
                'files' => [
                    'path' => '@app/secure',
                    'url' => ['file/download'],          // Through controller
                ],
            ],
        ],
        'urlManager' => [
            ...
            'rules' => [
                'download//' =>'file/download',
                ...
            ],
            ...
        ],
    ...
    ],

```

Create migration:

```
$ yii migrate/create path_organizer

```

and modify like:

```
