PHPackages                             el7cosmos/dirs - 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. el7cosmos/dirs

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

el7cosmos/dirs
==============

PHP Wrapper for dirs-rs

0.2.1(10mo ago)26[5 PRs](https://github.com/el7cosmos/dirs-php/pulls)PHP-3.01PHPCI passing

Since Jul 1Pushed 3mo agoCompare

[ Source](https://github.com/el7cosmos/dirs-php)[ Packagist](https://packagist.org/packages/el7cosmos/dirs)[ RSS](/packages/el7cosmos-dirs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (10)Used By (0)

PHP Wrapper for dirs-rs
=======================

[](#php-wrapper-for-dirs-rs)

A PHP extension that provides access to platform-specific directory paths by wrapping the Rust [dirs-rs](https://codeberg.org/dirs/dirs-rs) crate.

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

[](#installation)

You can install this extension using [Pie](https://github.com/php/pie):

```
pie install el7cosmos/dirs
```

Building from Source
--------------------

[](#building-from-source)

### Requirements

[](#requirements)

- PHP 8.0 or higher
- Rust toolchain

### Build

[](#build)

```
phpize
./configure
make
```

### Install

[](#install)

```
make install
```

Functions
---------

[](#functions)

This extension provides the following functions to retrieve platform-specific directory paths:

### Base Directories

[](#base-directories)

- `home_dir()`: Returns the path to the user's home directory
- `cache_dir()`: Returns the path to the user's cache directory
- `config_dir()`: Returns the path to the user's config directory
- `config_local_dir()`: Returns the path to the user's local config directory
- `data_dir()`: Returns the path to the user's data directory
- `data_local_dir()`: Returns the path to the user's local data directory
- `executable_dir()`: Returns the path to the user's executable directory
- `preference_dir()`: Returns the path to the user's preference directory
- `runtime_dir()`: Returns the path to the user's runtime directory
- `state_dir()`: Returns the path to the user's state directory

### User Directories

[](#user-directories)

- `audio_dir()`: Returns the path to the user's audio directory
- `desktop_dir()`: Returns the path to the user's desktop directory
- `document_dir()`: Returns the path to the user's document directory
- `download_dir()`: Returns the path to the user's download directory
- `font_dir()`: Returns the path to the user's font directory
- `picture_dir()`: Returns the path to the user's picture directory
- `public_dir()`: Returns the path to the user's public directory
- `template_dir()`: Returns the path to the user's template directory
- `video_dir()`: Returns the path to the user's video directory

All functions return either a string containing the path or `null` if the directory could not be determined.

Example Usage
-------------

[](#example-usage)

```
