Download the PHP package mb4it/filesystem without Composer

On this page you can find all versions of the php package mb4it/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

MB Filesystem

Lightweight wrapper around the local PHP filesystem with a convenient, predictable, exception‑based API.

Requirements

Installation

Basic usage

Working with JSON

Content and updateContent (plain files)

For non-JSON files you can use content() with an optional default and updateContent() for read-modify-write. updateContent() accepts either a path or a File object. For batch updates by path, prefer calling updateContent($path, $updater) with a string path so you avoid creating a File node per path (faster). The third parameter $atomic (default true) uses a temp file + rename so the file is never partially written on failure; pass false for higher throughput when crash-safety is not critical (e.g. logs, cache).

get() — get a node by path

get(string $path) returns a node representing the path — it does not return file content. The return type is File|Directory|Link:

Use content($path) or $file->content() to read file content as a string. Example:

File, Directory, and Link (nodes)

file(), directory(), and link() return rich nodes with metadata and operations. Use them to read, update, or delete without passing the path again. You can also obtain a node with get($path) (see above).

Node types and main methods

Node Main methods / metadata
File path, size, lastModified, extension, basename, filename, dirname, readable, writable, modecontent(), lines(), line($n), update(), write(), delete(), move(), copy(), chmod(), touch()
Directory path, lastModified, readable, writable, modefiles(), directories(), create(), delete($recursive), chmod(), touch()
Link path, target, isBroken, targetTypetarget(), isBroken(), resolve(): File|Directory|null, delete()

File

For large files use lines() instead of content() to avoid loading the whole file; use line($lineNumber) to read a single line by 1-based index.

Directory

Link (symlinks)

Create a symlink with createSymlink($target, $linkPath). Target can be relative (to the link’s directory) or absolute; link path must not exist. Use isLink($path) to check, link($path) to get a Link node. resolve() returns the target as File or Directory, or null if the link is broken.

Move, rename, and real path

move($from, $to) and rename($from, $to) do the same thing: move or rename a file, directory, or symlink. Both use PHP’s rename(); for directories, source and destination must be on the same filesystem.

realPath($path) returns the canonical absolute path (symlinks and ../. resolved). Throws if the path does not exist.

Directories and recursive operations

Masks and filtering

Metadata and write modes

Path helpers and base directory

Finding PHP classes by extends/implements/traits

The package provides a ClassFinder utility that can find classes by base parent, implemented interface, or used trait using static token-based parsing (no autoload, no ReflectionClass).

Search: grep and find

Four methods provide content search (grep-like) and path search (find-like). Path-only variants return string[] (lighter); node variants return File[] or File|Directory|Link[] for use with metadata and methods.

When to use which: Use grepPaths / findPaths when you only need paths or have very large result sets; use grep / find when you need node metadata or methods (content(), size, etc.). All are implemented in pure PHP (no shell).

Content search (grepPaths / grep)

Path search (findPaths / find)

Error handling

The package uses three custom exceptions:

It is recommended to handle them explicitly in your code:

Development

Running tests

Install dev dependencies and run the full test suite:

Or run PHPUnit directly (with optional config):

On Windows use vendor\bin\phpunit. Some tests (e.g. symlink creation) may be skipped if the environment does not support them (e.g. creating symlinks without Administrator or Developer Mode on Windows).

Running the benchmark

The benchmark measures performance of common operations (put/get, recursive listing, content search, file updates, etc.) and prints timing and memory statistics.

Or directly:

You can tune the run via environment variables; see benchmark/README.md for options (e.g. BENCH_FILES, BENCH_TREE_DEPTH, BENCH_LARGE_MB).


All versions of filesystem with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
mb4it/collections Version ^1.0
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 mb4it/filesystem contains the following files

Loading the files please wait ...