weevers/path 问题修复 & 功能扩展

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

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

weevers/path

最新稳定版本:v0.2.0

Composer 安装命令:

composer require weevers/path

包简介

PHP 5.4 port of the node/iojs path module

README 文档

README

PHP 5.4 port of the node/iojs path module, because PHP is like a family holiday dinner and I want to survive. Description from the iojs documentation:

This module contains utilities for handling and transforming file paths. Almost all these methods perform only string transformations. The file system is not consulted to check whether paths are valid.

packagist status Travis build status AppVeyor build status Dependency status

Jump to: usage / install / license

examples

Example output on a posix system, assuming "/please" is the current working directory:

<?php
use Weevers\Path\Path;

// "../../tolerate/php"
Path::relative('i/love/node', 'i/tolerate/php');

// "/alright" (resolve works like a sequence of cd commands in a shell)
Path::resolve('ah', '/okay', '../alright');

// true
Path::isInside('parent/child', 'parent');

// "/please/start/dancing"
Path::resolve('start', 'dancing');

?>

usage

Usage docs pending. In the meantime, consult the iojs documentation, because the function signatures are almost the same and the code (including unit tests) copied.

Ported so far (for posix and windows), including unit tests

  • relative($from, $to)
  • isAbsolute($path)
  • resolve($path, ..)
  • join($path, ..)
  • normalize($path)
  • separator()
  • delimiter()

PHP-specific additions

resolve() also accepts stream wrapper URI's. This is implemented outside of the (ported) posix and Windows adapters, to ensure it doesn't interfere with the original behavior (which remains well tested and has a frozen stability).

  • file schemes are stripped, unless combined with other schemes
  • A scheme change is interpreted like a root change. E.g. going from http://x to glob://x acts like a cd from c:\x to d:\x.
  • For remote streams (like http) and vfs streams, the arguments passed to resolve() are joined (instead of resolved to an absolute path) with forward slashes (regardless of OS).

Some examples (for Windows, so you can see the difference between local and remote streams), assuming "C:\project" is the current working directory:

<?php

// Relative input: "c:\project\beep"
Path::resolve('file://beep');
Path::resolve('beep');

// Absolute input: "c:\beep"
Path::resolve('file:///beep');
Path::resolve('/beep');

// Combined wrappers: "zip://file://c:\beep"
Path::resolve('zip://file:///beep');

// Remote stream, so forward slashes: "zip://http://example.com/blog/2015"
Path::resolve('zip://http://example.com\blog', '2015');

// "zip://c:\project\bar"
Path::resolve('zip://dir', '..', 'bar');
Path::resolve('dir', 'zip://..', 'bar');

// A VFS URI stays relative: "vfs://root/virtual.file"
Path::resolve('vfs://root', 'virtual.file');

// A scheme change: "glob://c:\project\*.js"
Path::resolve('http://example.com', 'glob://*.js');

// No scheme change: "glob://c:\project\dir\*.js"
Path::resolve('glob://dir', 'glob://*.js');

// UNC (a network path): "compress.zlib://\\server\share\resource"
// Note that "\\server\share" is the root, so ".." has no effect
Path::resolve('compress.zlib:////server/share', '..', 'resource');

?>

Additional methods

  • isInside($path, $parent) - similar to sindresorhus/is-path-inside for node
  • getPrefix($path) - returns "zip://" for "zip://2015.zip#april/02.log"

install

With composer do:

composer require weevers/path

license

MIT © Vincent Weevers and iojs/node authors.

weevers/path 适用场景与选型建议

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

它主要适用于以下技术方向: 「nodejs」 「path」 「node」 「utils」 「resolve」 「relative」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 weevers/path 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-31