定制 el7cosmos/dirs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

el7cosmos/dirs

最新稳定版本:0.2.1

Composer 安装命令:

pie install el7cosmos/dirs

包简介

PHP Wrapper for dirs-rs

README 文档

README

A PHP extension that provides access to platform-specific directory paths by wrapping the Rust dirs-rs crate.

Installation

You can install this extension using Pie:

pie install el7cosmos/dirs

Building from Source

Requirements

  • PHP 8.0 or higher
  • Rust toolchain

Build

phpize
./configure
make

Install

make install

Functions

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

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

  • 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

<?php
// Get user's home directory
$home = home_dir();
echo $home; // e.g., "/home/username"

// Get downloads directory
$downloads = download_dir();
echo $downloads; // e.g., "/home/username/Downloads"

Platform Support

This extension supports the following platforms:

  • Linux
  • macOS

The behavior on each platform follows the dirs-rs implementation.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: PHP-3.01
  • 更新时间: 2025-06-26