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.
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).
fileschemes are stripped, unless combined with other schemes- A scheme change is interpreted like a root change. E.g. going from
http://xtoglob://xacts like acdfromc:\xtod:\x. - For remote streams (like
http) and vfs streams, the arguments passed toresolve()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 nodegetPrefix($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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 weevers/path 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DNode RPC protocol for PHP 5.3
JSONPath implementation for querying and updating JSON objects with support for json flattening into a table
Send events to a websocket real time engine though PHP
The InstantConfigurationCopy module provides easy way to copy configuration field information for admin in back office Magento 2.
Send events to a websocket real time engine though PHP
simple agnostic package for IO releted (files, dir, etc..)
统计信息
- 总下载量: 31.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-31