azure-oss/storage-file-share 问题修复 & 功能扩展

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

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

azure-oss/storage-file-share

Composer 安装命令:

composer require azure-oss/storage-file-share

包简介

Azure Storage File Share PHP SDK

README 文档

README

Latest Version on Packagist Packagist Downloads

A PHP SDK for Azure File Share management and service operations that are not exposed through standard SMB or NFS mounts.

Important

This package is community-maintained and is not affiliated with, endorsed by, or supported by Microsoft.

Install

composer require azure-oss/storage-file-share

Scope

This package is not intended to replace an SMB or NFS mount.

If an operation is already handled well through a mounted Azure File Share, it is out of scope for this SDK. That includes routine filesystem-style work such as creating directories, reading files, writing files, renaming paths, and deleting content through the mounted share.

The purpose of this package is the opposite boundary: it should cover Azure Files capabilities that are not available through a normal mount, or are not practical to manage through one. That includes Azure-specific management, metadata, protocol-specific service features, and other control-plane or service-plane operations that need the Azure Files API rather than ordinary filesystem calls.

In short:

  • Use SMB or NFS mounts for normal file and directory manipulation.
  • Use azure-oss/storage-file-share for Azure Files features that a mount does not expose.

SAS generation

This package includes a minimal client hierarchy and File Share service SAS builder for share and path-based SAS URIs.

SAS generation requires a StorageSharedKeyCredential. Clients created from a SAS-only connection string can use that SAS, but they cannot generate a new SAS.

UseDevelopmentStorage=true is not supported for this package. Azurite does not currently provide Azure Files endpoints, so File Share clients must target a real File service endpoint.

Azure Files service SAS distinguishes share (sr=s) and file (sr=f) resources. When you generate a SAS from a ShareDirectoryClient, the directory path is signed using the file-path form, matching the current Azure .NET SDK behavior.

use AzureOss\Storage\File\Share\Sas\ShareFileSasPermissions;
use AzureOss\Storage\File\Share\Sas\ShareSasBuilder;
use AzureOss\Storage\File\Share\ShareServiceClient;

$service = ShareServiceClient::fromConnectionString($_ENV['AZURE_STORAGE_CONNECTION_STRING']);

$file = $service
    ->getShareClient('documents')
    ->getDirectoryClient('reports/2026')
    ->getFileClient('summary.txt');

$sasUri = $file->generateSasUri(
    ShareSasBuilder::new()
        ->setPermissions(new ShareFileSasPermissions(read: true))
        ->setExpiresOn(new DateTimeImmutable('+15 minutes')),
);

Related packages

Maintenance

This package is part of the community-maintained PHP OSS for Azure project. It is an independent project and is not affiliated with or endorsed by Microsoft.

License

This project is released under the MIT License. See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-30