Download the PHP package nelwhix/filepath without Composer
On this page you can find all versions of the php package nelwhix/filepath. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nelwhix/filepath
More information about nelwhix/filepath
Files in nelwhix/filepath
Package filepath
Short Description file i/o utilities for different OS architectures
License
Informations about the package filepath
Filepath
A simple class with some static methods for manipulating file paths properly regardless of system architecture
Motivation
I was working on a legacy PHP project where there was all sort of code like this:
I then remembered that golang's filepath package would fluently join a url like this. So this is a port of the methods in golang's path/filepath package
Installation
Usage
-
Join Method: Using the static 'join' method the code for the example earlier will look like this:
-
Base method: The base method returns the last part of any filepath passed to it. Like this:
-
Abs method: The abs method returns the absolute path to the filepath given:
-
Dir method: The dir method returns the directory in a path:
-
clean method: The clean method removes double and trailing slashes from a filepath e.g.
-
ext method: The ext method returns the extension of the file in the filepath. if a directory is passed it returns an empty string.
-
split method: The split method returns an object that contains the directory and file from the filepath
-
walk method: The walk method takes a directory and a callback function to run on each file in the directory.
- glob method: The glob method returns all the files in a directory that match a pattern. To return all the files ending in ".php":