PHPackages                             josantonius/file - 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. josantonius/file

Abandoned → [symfony/filesystem](/?search=symfony%2Ffilesystem)ArchivedLibrary[File &amp; Storage](/categories/file-storage)

josantonius/file
================

PHP library for file management.

1.1.8(3y ago)131.3k↑900%7MITPHPPHP ^5.6 || ^7.0

Since Jan 17Pushed 3y ago3 watchersCompare

[ Source](https://github.com/josantonius/php-file)[ Packagist](https://packagist.org/packages/josantonius/file)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-file/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (11)Used By (0)

PHP File library
================

[](#php-file-library)

[![Latest Stable Version](https://camo.githubusercontent.com/eab4f24f3abbc4036eaa24278e5f8ff40a23ce99f5c062233eb24f945919390d/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f46696c652f762f737461626c65)](https://packagist.org/packages/josantonius/File)[![License](https://camo.githubusercontent.com/4d3da56fa96b39854aa5abc6756a85da3202779ef0ff6de962f3db29d68c9ed9/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f46696c652f6c6963656e7365)](LICENSE)

[Versión en español](README-ES.md)

PHP library for file management.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [License](#license)

---

Requirements
------------

[](#requirements)

This library is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher.

Installation
------------

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP File library**, simply:

```
composer require Josantonius/File

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require Josantonius/File --prefer-source

```

You can also **clone the complete repository** with Git:

$ git clone

Or **install it manually**:

[Download File.php](https://raw.githubusercontent.com/Josantonius/PHP-File/master/src/File.php):

```
wget https://raw.githubusercontent.com/Josantonius/PHP-File/master/src/File.php

```

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Check if a file exists in a path or url

[](#--check-if-a-file-exists-in-a-path-or-url)

```
File::exists($file);
```

AttributeDescriptionTypeRequiredDefault$filePath or file url.stringYes**\# Return** (boolean)

### - Delete file if exists

[](#--delete-file-if-exists)

```
File::delete($file);
```

AttributeDescriptionTypeRequiredDefault$fileFile path.stringYes**\# Return** (boolean)

### - Create directory if not exists

[](#--create-directory-if-not-exists)

```
File::createDir($path);
```

AttributeDescriptionTypeRequiredDefault$pathPath where to create directory.stringYes**\# Return** (boolean)

### - Copy directory recursively

[](#--copy-directory-recursively)

```
File::copyDirRecursively($from, $to);
```

AttributeDescriptionTypeRequiredDefault$fromPath from copy.stringYes$toPath to copy.stringYes**\# Return** (boolean)

### - Delete empty directory

[](#--delete-empty-directory)

```
File::deleteEmptyDir($path);
```

AttributeDescriptionTypeRequiredDefault$pathPath to delete.stringYes**\# Return** (boolean)

### - Delete directory recursively

[](#--delete-directory-recursively)

```
File::deleteDirRecursively($path);
```

AttributeDescriptionTypeRequiredDefault$pathPath to delete.stringYes**\# Return** (boolean)

### - Get files from directory

[](#--get-files-from-directory)

```
File::getFilesFromDir($path);
```

AttributeDescriptionTypeRequiredDefault$pathPath where get file paths.stringYes**\# Return** (boolean)

Quick Start
-----------

[](#quick-start)

To use this library with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\File\File;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/File.php';

use Josantonius\File\File;
```

Usage
-----

[](#usage)

Example of use for this library:

### - Check if a local file exists

[](#--check-if-a-local-file-exists)

```
File::exists('path/to/file.php');
```

### - Check if a external file exists

[](#--check-if-a-external-file-exists)

```
File::exists('https://raw.githubusercontent.com/Josantonius/PHP-File/master/composer.json');
```

### - Delete a local file

[](#--delete-a-local-file)

```
File::delete(__DIR__ . '/test.txt');
```

### - Create directory

[](#--create-directory)

```
File::createDir(__DIR__ . '/test/');
```

### - Delete empty directory

[](#--delete-empty-directory-1)

```
File::deleteEmptyDir(__DIR__ . '/test/');
```

### - Delete directory recursively

[](#--delete-directory-recursively-1)

```
File::deleteDirRecursively(__DIR__ . '/test/');
```

### - Copy directory recursively

[](#--copy-directory-recursively-1)

```
File::copyDirRecursively(__DIR__ . '/test/', __DIR__ . '/copy/');
```

### - Get file paths from directory

[](#--get-file-paths-from-directory)

```
get_class(File::getFilesFromDir(__DIR__));
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/Josantonius/PHP-File.git

cd PHP-File

composer install

```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit

```

Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs

```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd

```

Run all previous tests:

```
composer tests

```

License
-------

[](#license)

This repository is licensed under the [MIT License](LICENSE).

Copyright © 2017 - 2022, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~254 days

Recently: every ~441 days

Total

9

Last Release

1370d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0

1.1.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

[![josantonius](https://avatars.githubusercontent.com/u/18104336?v=4)](https://github.com/josantonius "josantonius (26 commits)")

---

Tags

phpphp-file-managerphp-filemanagerphp-filesphp-libraryphpfilestringshhvmSearch words in fileFile handler

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josantonius-file/health.svg)

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

###  Alternatives

[blueimp/jquery-file-upload

File Upload widget for jQuery.

141.5M18](/packages/blueimp-jquery-file-upload)[davaxi/vcalendar

PHP Class to generate VCalendar (ics) file

1180.8k](/packages/davaxi-vcalendar)

PHPackages © 2026

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