xdg/base-directory 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xdg/base-directory

Composer 安装命令:

composer require xdg/base-directory

包简介

Implementation of the XDG Base Directory Specification

README 文档

README

codecov

PHP implementation of the XDG Base Directory Specification, with sensible default fallbacks for non-linux platforms.

Installation

composer require xdg/base-directory

Usage

use Xdg\BaseDirectory\XdgBaseDirectory;

// we start by instantiating a platform:
$platform = XdgBaseDirectory::fromEnvironment();
// get the XDG_CONFIG_HOME directory
$configHome = $platform->getConfigHome();
// find the most user-specific existing configuration file:
$configPath = $platform->findConfigPath('my-app/config.json', \file_exists(...));

See the PlatformInterface for all available platform methods.

Fallback values for Windows and macOS platforms

While on most Unix platforms, the XDG environment variables are usually defined, this is typically not the case on Windows and macOS.

This library choses to deviate from the spec and provide sensible defaults on those platforms.

Windows

On windows, when an XDG environment variable is not set, we first try to find a matching Known Folder:

XDG env Known Folder(s)
HOME Profile
XDG_CONFIG_HOME LocalAppData
XDG_DATA_HOME LocalAppData
XDG_STATE_HOME LocalAppData
XDG_CACHE_HOME LocalAppData/cache
XDG_RUNTIME_DIR LocalAppData
XDG_CONFIG_DIRS ProgramData, RoamingAppData
XDG_DATA_DIRS RoamingAppData, ProgramData

If the known folder is not defined, we then try to fall back to a windows-specific environment variable, then fall back to a static default:

KnownFolder Windows env default
Profile USERPROFILE, HOMEDRIVE + HOMEPATH 🚨 Error 🚨
LocalAppData LOCALAPPDATA $HOME/AppData/Local
RoamingAppData APPDATA $HOME/AppData/Roaming
ProgramData ProgramData %SystemDrive%/ProgramData, C:/ProgramData

MacOS

XDG env Fallback
XDG_CONFIG_HOME $HOME/Library/Application Support
XDG_DATA_HOME $HOME/Library/Application Support
XDG_STATE_HOME $HOME/Library/Application Support
XDG_CACHE_HOME $HOME/Library/caches
XDG_RUNTIME_DIR $HOME/Library/Application Support
XDG_CONFIG_DIRS $HOME/Library/Preferences, /Library/Application Support, /Library/Preferences
XDG_DATA_DIRS /Library/Application Support

xdg/base-directory 适用场景与选型建议

xdg/base-directory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 458 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 xdg/base-directory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xdg/base-directory 我们能提供哪些服务?
定制开发 / 二次开发

基于 xdg/base-directory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 458
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-03