PHPackages                             struam/dir-rotation - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. struam/dir-rotation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

struam/dir-rotation
===================

PHP library for directory rotation

1.0.0(1y ago)03PHPPHP &gt;=8.3

Since Jan 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Struam/dir-rotation)[ Packagist](https://packagist.org/packages/struam/dir-rotation)[ RSS](/packages/struam-dir-rotation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

DirRotation
===========

[](#dirrotation)

`DirRotation` — is a library for managing directories and files in PHP. It provides methods for creating, deleting, archiving, and changing the working directory.

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

[](#installation)

To install the library, use Composer:

```
composer require struam/dir-rotation
```

Usage
-----

[](#usage)

### Example of usage

[](#example-of-usage)

```
require 'vendor/autoload.php';

use Struam\DirRotation\DirRotation;

try {

    // Initialization without specifying the working directory
    $dirRotation = new DirRotation();
    echo "Working Directory: " . $dirRotation->getWorkingDirectory();

    // Creating a subdirectory
    $subdirectoryPath = $dirRotation->createSubdirectory('dir/new/temp');
    echo "Subdirectory created at: " . $subdirectoryPath;

    // Archiving a subdirectory followed by deletion
    $archivePath = $dirRotation->archiveDirectory('dir/new/temp', true);
    echo "Directory archived at: " . $archivePath;

    // Changing the working directory
    $dirRotation->changeWorkingDirectory('/new/working/directory');
    echo "Working Directory changed to: " . $dirRotation->getWorkingDirectory();

} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

### Methods

[](#methods)

#### \_\_construct(string $workingDirectory = null)

[](#__constructstring-workingdirectory--null)

Initializes the DirRotation object with the specified working directory. If the working directory is not specified, the current working directory is used.

- $workingDirectory (string|null)

Example:

'../', '../dir', '/var/project/dir', 'dir'

#### getWorkingDirectory()

[](#getworkingdirectory)

Returns the current working directory.

#### changeWorkingDirectory(string $workingDirectory)

[](#changeworkingdirectorystring-workingdirectory)

Changes the current working directory to the specified one.

- $workingDirectory (string)

Example:

'../', '../dir', '/var/project/dir', 'dir'

#### createSubdirectory(string $path)

[](#createsubdirectorystring-path)

Creates a subdirectory in the working directory.

- $path (string)

Example:

'dir', '/dir/new-dir', '/dir/new-dir/some-dir'

#### deleteSubdirectory(string $path)

[](#deletesubdirectorystring-path)

Deletes a subdirectory from the working directory.

- $path (string)

Example:

'dir', '/dir/new-dir', '/dir/new-dir/some-dir'

#### archiveDirectory(string $path,bool $deleteAfterArchive = false)

[](#archivedirectorystring-pathbool-deleteafterarchive--false)

Archives the specified directory and saves the archive in the parent directory.

Example:

Archive directory: '/dir/new-dir'

Current working directory: '/var/project/'

The archive will be saved in the directory: '/var/project/dir/new-dir.zip'

- $path (string)

The path to the directory to be archived.

Example:

'dir', '/dir/new-dir', '/dir/new-dir/some-dir'

- $deleteAfterArchive (bool)

If true, the directory will be deleted after archiving. Default is false.

License
-------

[](#license)

This library is distributed under the MIT License. See the LICENSE file for details.

Contributing
------------

[](#contributing)

Contributions and suggestions for improving the library are welcome. Please create an issue or pull request.

Author
------

[](#author)

Rustam Kadirov

Version History
---------------

[](#version-history)

1.0.0 First release

This `README.md` file provides essential information about the library, including installation, usage, testing, and licensing. You can adapt it to your needs by adding additional sections or modifying existing ones.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance41

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

486d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a073af837e8895f49240882bbaf58a646c975a0bb9f56eb254f9365afc5047a?d=identicon)[Struam](/maintainers/Struam)

---

Top Contributors

[![Struam](https://avatars.githubusercontent.com/u/96293425?v=4)](https://github.com/Struam "Struam (3 commits)")

---

Tags

dirphp8.3rotation

### Embed Badge

![Health badge](/badges/struam-dir-rotation/health.svg)

```
[![Health](https://phpackages.com/badges/struam-dir-rotation/health.svg)](https://phpackages.com/packages/struam-dir-rotation)
```

PHPackages © 2026

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