Download the PHP package ricwein/filesystem without Composer

On this page you can find all versions of the php package ricwein/filesystem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filesystem

FileSystem

This Library provides a Filesystem abstraction layer.

Installation

Overview

Let's begin with a short overview over the supported Filesystem classes and abstractions.

All classes uses the root-namespace ricwein\FileSystem.

Object-Types

A File is represented as a File Object and a Directory as a Directory Object.

Storage

Accessing the Objects (File/Directory) Content is abstracted as Storages. A File can be either:

All Storage-Types must extend the abstract base class Filesystem\Storage.

WARNING: since storage-objects are mutable and php automatically handles class-objects as references when passed into a function (constructor), it's highly recommended using the clone keyword when storages are recycled between to FileSystem-Objects. DO NOT:

DO:

Exceptions

Accessing File/Directory Attributes can result in throwing Exceptions. All Exceptions implement the Exceptions\FileSystemException Interface.

Usage: Files

All FileSystem-base-classes must be initialized using a Storage.

Methods

method description
read(?$offset, ?$length, $mode) read and return file-content, allows partial read with $offset and $length parameters, file is locked while reading with $mode
stream(?$offset, ?$length, $mode) stream file into output-buffer, file is locked while reading with $mode
write($content, $append, $mode) write $content to file, creates new file if it doesn't already exists, allows appended writing if $append isset, locks file with $mode
copyTo($destination [,Constraint $constraints]) copy file to new $destination Storage-adapter
moveTo($destination [,Constraint $constraints]) like copyTo(), but moves files instead
touch([bool $ifNewOnly]) create file if it doesn't exists, updates last-modified timestamp
remove() try to remove file
getType([bool $withEncoding]) guess files mime-type
getTime([Time $type]) get last-modified unix-timestamp
getDate([Time $type]) same as getTime(), but returns a DateTime object instead
getSize() calculate size
getHash([Hash $mode [,string $algo [,bool $raw]]]) calculates a hash over $mode with $algo algorithm
isReadable() is file readable?
isWriteable() is file writeable?
isSymlink() is file a symlink?
isFile() is selected path an actual file?
isDir() is selected path a directory? => always false for File instance
isDotfile() is file a hidden dot-file?
isValid() run constraints validation
getHandle([string $mode]) gets new file-Handle for binary file-access
storage() access internal storage adapter
getPath() fetch filesystem-path
getStream() returns Stream wrapper around internal resource pointing to actual file
dir([,int $constraints [,string $as [,...$arguments]]]) get parent Directory of file

Open and read a file from the local filesystem

or from in-memory-file

or from stream

or from a Flysystem object

Usage: Directories

Like Files, Directories must be initialized using a Storage.

Methods

method description
list($recursive) returns DirectoryIterator-Object to list directory-content as new File/Directory objects
mkdir() try to create directory
remove() try to remove directory
copyTo($destination [,Constraint $constraints]) copy directory recursively to new $destination Storage-adapter
getTime([Time $type]) get last-modified unix-timestamp
getDate([Time $type]) same as getTime(), but returns a DateTime object instead
getSize([bool $recursive]) calculate size
getHash([Hash $mode [,string $algo [,bool $raw]]]) calculates a hash over $mode with $algo algorithm
isReadable() is directory readable?
isWriteable() is directory writeable?
isSymlink() is directory a symlink?
isFile() is selected path a file? => always false for Directory instance
isDir() is selected path an actual directory?
isDotfile() is directory a hidden dot-file?
isValid() run constraints validation
storage() access internal storage adapter
getPath() fetch filesystem-path
file(string $filename [,int $constraints [,string $as [,...$arguments]]]) get File in current directory by name
dir(string $dirname [,int $constraints [,string $as [,...$arguments]]]) get Directory in current directory by name (clones storage!)

check if directory is readable

list all files inside a directory

Security

Using this filesystem-layer also provides some kind of security for usage with user-defined file-paths. Accessing file attributes or content is only done after checking against so called Constraints.

Constraints

Constraints are defined on initialization of File or Directory objects and are stored inside the internal Storage object. This allows Constraints-inheritance, if new FileSystem-objects are accessed from existing ones. Example:

In this example, the $file object shares the Constraints (inherited) and safepath with $dir - allowing safely accessing a file in $dir from user defined parameters. Path traversal is therefore prevented.

The following constraints are set as default (as part of Constraint::STRICT), but can be overwritten with the second argument of the File($storage, $constraints) or Directory($storage, $constraints) constructor:

Extensions

Directory Extensions

File Extensions

Be aware: all image-file manipulations are directly mutating the original file!

Storage Extensions

ATTENTION: Usually it's a better idea to just use Storage\Stream instead!


All versions of filesystem with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-fileinfo Version *
ext-zip Version *
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ricwein/filesystem contains the following files

Loading the files please wait ....