PHPackages                             ryanve/slash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. ryanve/slash

ActiveLibrary[File &amp; Storage](/categories/file-storage)

ryanve/slash
============

URI and filesystem path utilities.

3.0.0(12y ago)165303MITPHPPHP &gt;=5.4

Since Jan 9Pushed 12y ago2 watchersCompare

[ Source](https://github.com/ryanve/slash)[ Packagist](https://packagist.org/packages/ryanve/slash)[ Docs](https://github.com/ryanve/slash)[ RSS](/packages/ryanve-slash/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

[slash](../../)
===============

[](#slash)

#### PHP utility classes for URIs, paths, and files

[](#php-utility-classes-for-uris-paths-and-files)

API ([3.0](../../releases))
---------------------------

[](#api-30)

### Classes

[](#classes)

- [**Uri**](#uri-methods) methods aim to be more practical and reliable than [`parse_url`](http://www.php.net/manual/en/function.parse-url.php).
- [**Path**](#path-methods) contains reliable methods for working with server filesystem paths.
- [**File**](#file-methods) contains reliable methods for reading and writing files.
- [**Slash**](#slash-methods) contains string utilities inherited by `Path` and `Uri`.

### [`Uri`](./slash/Uri.php) Methods

[](#uri-methods)

```
foo://user:pass@example.com:800/dir/file.php?s=10&e=23#jump
\_/   \_______/ \_________/ \_/              \_______/ \__/
 |        |          |       |                  |       |
 |     userinfo   hostname  port              query   fragment
 |    \_______________________/\___________/
 |            |                      |
scheme    authority                 path
```

#### Methods are based on the [URI diagram](http://en.wikipedia.org/wiki/URI_scheme#Examples) or otherwise normalized between terms in [PHP](http://www.php.net/manual/en/function.parse-url.php), [JavaScript](https://developer.mozilla.org/en-US/docs/DOM/window.location), [jQuery Mobile](http://jquerymobile.com/test/docs/api/methods.html), and [node](http://nodejs.org/docs/v0.5.5/api/url.html).

[](#methods-are-based-on-the-uri-diagram-or-otherwise-normalized-between-terms-in-php-javascript-jquery-mobile-and-node)

```
\slash\Uri::scheme($uri) // get scheme (excludes ':')
\slash\Uri::prorel($uri) // convert to protocol relative
\slash\Uri::prorel($uri, $scheme) // replace the scheme
\slash\Uri::bar($uri) // get "address bar" uri
\slash\Uri::authority($uri) // get authority
\slash\Uri::hostname($uri) // get hostname
\slash\Uri::prefetch($uri) // get uri for dns prefetch
\slash\Uri::userinfo($uri) // get userinfo
\slash\Uri::user($uri) // get username
\slash\Uri::pass($uri) // get password
\slash\Uri::port($uri) // get port number (string)
\slash\Uri::hier($uri) // get hierarchial part
\slash\Uri::path($uri) // get path part
\slash\Uri::query($uri) // get query str (excludes '?')
\slash\Uri::hash($uri) // get fragment  (includes '#')
\slash\Uri::fragment($uri) // get fragment  (excludes '#')
\slash\Uri::nohash($uri) // remove hash
\slash\Uri::novars($uri) // remove hash and query
\slash\Uri::parse($uri) // get object containing parts
```

### [`Slash`](./slash/Slash.php) Methods

[](#slash-methods)

```
\slash\Slash::trim($path)
\slash\Slash::ltrim($path)
\slash\Slash::rtrim($path)
\slash\Slash::slash($path)
\slash\Slash::lslash($path)
\slash\Slash::rslash($path)
\slash\Slash::join(*$parts)
\slash\Slash::split($path)
\slash\Slash::normalize($path)
```

### [`File`](./slash/File.php) Methods

[](#file-methods)

```
\slash\File::exists($path)
\slash\File::get($path, $done?)
\slash\File::put($path, $data)
\slash\File::load($path, $done)
\slash\File::getJson($path, $done?)
\slash\File::putJson($path, $data)
```

### [`Path`](./slash/Path.php) Methods

[](#path-methods)

```
\slash\Path::normalize($path)
\slash\Path::root($relative?)
\slash\Path::dir($relative?)
\slash\Path::ext($path, $add?)
\slash\Path::filename($file)
\slash\Path::inc($file)
\slash\Path::scan($path?)
\slash\Path::tree($path?)
\slash\Path::paths($path?)
\slash\Path::files($path?)
\slash\Path::dirs($path?)
\slash\Path::exists($item)
\slash\Path::isPath($item)
\slash\Path::isFile($item)
\slash\Path::isDir($item)
\slash\Path::isDot($item)
\slash\Path::isAbs($path) // test if path is absolute
\slash\Path::toAbs($path) // resolve relative path
\slash\Path::toUri($path, $scheme?) // defaults to protocol-relative
\slash\Path::toUrl($path, $scheme?) // defaults to http or https
\slash\Path::isHttps()
\slash\Path::mtime($path)
\slash\Path::ctime($path)
\slash\Path::atime($path)
\slash\Path::affix($list, $prefix, $suffix?)
\slash\Path::infix($list, $infix)
\slash\Path::depth($path)
\slash\Path::tier($array)
\slash\Path::sort($array)
\slash\Path::locate($needles)
\slash\Path::contains($haystack, $needle)
\slash\Path::search($paths, $needles?)
\slash\Path::find($list, $test)
```

### [`Mixin`](./slash/traits/Mixin.php) Methods

[](#mixin-methods)

#### Extend Any [Class](#classes)

[](#extend-any-class)

```
::mixin($name, $fn) // mixin a single method
::mixin($array) // mixin methods from an associative array
::mixin($object) // mixin methods from an object or class
::method($name) // fully-qualify a method (returns callable)
::methods($object?) // get array of all methods incl. mixins
```

Fund
----

[](#fund)

Fund development with [tips to @ryanve](https://www.gittip.com/ryanve/) =)

[MIT License](http://opensource.org/licenses/MIT)
-------------------------------------------------

[](#mit-license)

Copyright (C) 2013 by [Ryan Van Etten](https://github.com/ryanve)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4556d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/949985?v=4)[ryan neptune](/maintainers/ryanve)[@ryanve](https://github.com/ryanve)

---

Top Contributors

[![ryanve](https://avatars.githubusercontent.com/u/949985?v=4)](https://github.com/ryanve "ryanve (76 commits)")

---

Tags

phpslashuriurlurlurijsonfilesystemutilitypathfiledirectory

### Embed Badge

![Health badge](/badges/ryanve-slash/health.svg)

```
[![Health](https://phpackages.com/badges/ryanve-slash/health.svg)](https://phpackages.com/packages/ryanve-slash)
```

###  Alternatives

[wikimedia/relpath

Work with file paths to join or find the relative path

13933.5k3](/packages/wikimedia-relpath)[internal/path

Type-safe, immutable file path library with cross-platform support and automatic normalization.

12117.0k10](/packages/internal-path)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
