PHPackages                             machitgarha/phirs - 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. [CLI &amp; Console](/categories/cli)
4. /
5. machitgarha/phirs

ActiveLibrary[CLI &amp; Console](/categories/cli)

machitgarha/phirs
=================

Cross-platform user directory paths, such as config and cache

0.1.0(4y ago)8243Apache-2.0PHPPHP ^7.4|^8.0

Since Feb 19Pushed 4y ago2 watchersCompare

[ Source](https://github.com/machitgarha/phirs)[ Packagist](https://packagist.org/packages/machitgarha/phirs)[ Docs](https://github.com/machitgarha/phirs)[ RSS](/packages/machitgarha-phirs/feed)WikiDiscussions master Synced 4w ago

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

Phirs
=====

[](#phirs)

[![Continuous Integration](https://github.com/machitgarha/phirs/actions/workflows/ci.yml/badge.svg)](https://github.com/machitgarha/phirs/actions/workflows/ci.yml)

A library providing platform-specific user directory paths, such as config and cache. Inspired by [dirs-rs](https://github.com/dirs-dev/dirs-rs).

Features
--------

[](#features)

- **Multiple Platform.** Providing cross-platform paths, plus platform-specific ones. Make your app run-everywhere or target a specific platform. See [Platform Support](#platform-support) for more details.
- **Hackable.** Adding support for a specific platform [is easy](./docs/en/usage-guide.md#example-android-platform-support).
- **Well-Designed.** Provide good design and simple abstractions (with the help of powerful PHP interfaces and traits).
- **Well-Tested.** Many pieces of the library are covered by unit tests. With the help of CI tools also, it is continuously tested againts major platforms.

Why?
----

[](#why)

When writing a console application (or even a graphical one; who knows, people might start writing graphical applications in PHP in near future), sometimes you need to have a location to:

- store your configurations, and possibly re-use them in the future runs,
- make cache files and improve the performance of your application,
- create a media and put it somewhere reasonable,
- etc.

For the best results, the locations should be cross-platform, permanent, accessible (i.e. both readable and writable), well-known and non-relative.

Phirs can help you in these situations.

**Note:** The library does not guarantee that all provided paths meet all the conditions above, although it helps you achieving them. The reason is performance, and the fact that different users may have different needs (e.g. one may check for a path to exist, one may suppose it to exist). Theoretically, in a standard environment and for standard paths, all these conditions are met (although the directories might not actually exist).

### But There Is Another Library!

[](#but-there-is-another-library)

Why not just using [Basedir](https://github.com/clue-labs/php-basedir)?

Go back and see [features](#features). Having these there would require a major rewrite and huge backward-compatibility break. Plus, Basedir is [no longer available on Packagist](https://packagist.org/search/?q=basedir), for some unknown reason.

Requirements
------------

[](#requirements)

PHP 7.4+ only.

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

[](#installation)

Easy like every other PHP library:

```
composer install machitgarha/phirs

```

Basic Usage
-----------

[](#basic-usage)

A simple use for most common cases is the following:

```
use MAChitgarha\Phirs\DirectoryProviderFactory;
use MAChitgarha\Phirs\Util\Platform;

// Get a provider for the current platform
$dirProvider = DirectoryProviderFactory::createStandard(Platform::autoDetect());

// Let's get some paths!
$configPath = $dirProvider->getConfigPath();
$docsPath = $dirProvider->getDocumentsPath();

// Load or save something…!
```

What a provider is? Why we use `createStandard()`? Can I extend it and map a specific platform to my own provider? See [Usage Guide](./docs/en/usage-guide.md) for more details.

Platform Support
----------------

[](#platform-support)

PlatformHaving a Provider?Supported?Working?Having a Specialized Provider?GNU/Linux distributions✅✅✅✅Windows✅✅✅✅Mac OS✅✅✅✅[Termux](https://termux.com) on Android✅✅✅❕(1)❌BSD✅❌❔❌Solaris✅❌❔❌Android✅❌❓❌iOS✅❌❓❌- ❕: Has notes.
- ❔: Not known or depends on the environment.
- ❓: Like ❔, but most likely no.

### Notes

[](#notes)

1. It might not be exactly what you or users expect; e.g. pictures directory path is inside Termux home, not the internal SDCard (i.e. `/sdcard`).

Contribute!
-----------

[](#contribute)

In a world like this, everyone should be a contributor. So, start helping this project by creating an issue, forking and improving it, or simply introducing it to your PHP developer friends!

If you want to get an overall overview of the code, go and read [Usage Guide](#usage-guide).

For the best results, see [Contribution Guidelines](./.github/CONTRIBUTING.md).

License
-------

[](#license)

The project is licensed under [Apache 2.0 License](./LICENSE.md).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

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

Every ~0 days

Total

2

Last Release

1539d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4037ee453cec41c146cd92c4ccb22350dd84c1227c2bbc8b15eb04513e9d97e?d=identicon)[MAChitgarha](/maintainers/MAChitgarha)

---

Top Contributors

[![machitgarha](https://avatars.githubusercontent.com/u/14151550?v=4)](https://github.com/machitgarha "machitgarha (98 commits)")

---

Tags

basedirclidirectorieshomedirpathphpxdg-basedir

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/machitgarha-phirs/health.svg)

```
[![Health](https://phpackages.com/badges/machitgarha-phirs/health.svg)](https://phpackages.com/packages/machitgarha-phirs)
```

###  Alternatives

[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k57.4M677](/packages/drush-drush)[humbug/php-scoper

Prefixes all PHP namespaces in a file or directory.

7963.0M34](/packages/humbug-php-scoper)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[consolidation/self-update

Provides a self:update command for Symfony Console applications.

10457.0M22](/packages/consolidation-self-update)[drupal/console-core

Drupal Console Core

13514.7M12](/packages/drupal-console-core)

PHPackages © 2026

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