# dnoegel/php-xdg-base-dir

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/dnoegel-php-xdg-base-dir).**

6,295 stars · 11 forks · PHP · MIT

## Links

- GitHub: https://github.com/dnoegel/php-xdg-base-dir
- awesome-repositories: https://awesome-repositories.com/repository/dnoegel-php-xdg-base-dir.md

## Description

php-xdg-base-dir is a PHP library and system path resolver designed to identify standard filesystem locations for application configuration, cache, and runtime files. It provides an implementation of the XDG Base Directory specification to organize user-specific data and configuration across different platforms.

The library resolves directory paths by mapping standard categories to filesystem locations based on Freedesktop.org standards. It manages cross-platform file organization by detecting the operating system and applying corresponding default paths.

The resolution process utilizes a prioritized hierarchy that checks system environment variables before falling back to operating system defaults. This ensures that PHP scripts respect system standards and avoid cluttering user home directories.

## Tags

### Operating Systems & Systems Programming

- [XDG Specification Compliance](https://awesome-repositories.com/f/operating-systems-systems-programming/xdg-specification-compliance.md) — Implements the XDG Base Directory Specification to map configuration, data, and cache categories to filesystem locations.
- [Cross-Platform Path Abstractions](https://awesome-repositories.com/f/operating-systems-systems-programming/system-administration-maintenance/file-system-management/file-system-utilities/cross-platform-path-abstractions.md) — Organizes application files across different operating systems using standardized paths for data and runtime storage.
- [Unix Standard Path Libraries](https://awesome-repositories.com/f/operating-systems-systems-programming/unix-standard-path-libraries.md) — Implements Freedesktop.org standards for organizing user-specific configuration and data directories.

### Development Tools & Productivity

- [Fallback Hierarchies](https://awesome-repositories.com/f/development-tools-productivity/path-resolvers/fallback-hierarchies.md) — Implements a prioritized hierarchy of potential paths to ensure a valid system directory is identified.
- [Application Data Path Resolvers](https://awesome-repositories.com/f/development-tools-productivity/file-filtering-utilities/file-path-locators/application-data-path-resolvers.md) — Identifies specific directory paths where Linux applications should store internal data and configuration files.

### Programming Languages & Runtimes

- [Environment Variable Resolution](https://awesome-repositories.com/f/programming-languages-runtimes/environment-variable-resolution.md) — Resolves system directory paths by retrieving and expanding environment variables before applying defaults.
- [PHP System Path Utilities](https://awesome-repositories.com/f/programming-languages-runtimes/php-system-path-utilities.md) — Provides a mechanism for PHP scripts to discover system paths that respect environment variables and OS standards.

### Software Engineering & Architecture

- [Configuration Path Resolution](https://awesome-repositories.com/f/software-engineering-architecture/directory-based-version-resolution/configuration-path-resolution.md) — Identifies the correct directory paths for application configuration, data, cache, and runtime files. ([source](https://github.com/dnoegel/php-xdg-base-dir/blob/master/README.md))
- [Runtime Path Resolvers](https://awesome-repositories.com/f/software-engineering-architecture/runtime-path-resolvers.md) — Determines the correct directory locations for application configuration, cache, and runtime files across platforms.

### System Administration & Monitoring

- [OS-Specific Default Paths](https://awesome-repositories.com/f/system-administration-monitoring/os-defaults-collections/os-specific-default-paths.md) — Provides hardcoded default paths based on the detected operating system when environment overrides are absent.
