PHPackages                             scaleplan/access-to-files - 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. [Caching](/categories/caching)
4. /
5. scaleplan/access-to-files

ActiveLibrary[Caching](/categories/caching)

scaleplan/access-to-files
=========================

Caching files with Redis, PHP and Nginx

153PHP

Since Nov 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/scaleplan/access-to-files)[ Packagist](https://packagist.org/packages/scaleplan/access-to-files)[ RSS](/packages/scaleplan-access-to-files/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

AccessToFiles
=============

[](#accesstofiles)

Control access to private files.

#### Installation

[](#installation)

`composer reqire scaleplan/access-to-files`

#### How it works

[](#how-it-works)

Suppose we need to give access to the  **document.pdf**  file for  **1 hour**  and to the  **picture.jpg**  file for 5 minutes to the currently authorized user. And these files are by default inaccessible to this user.

First, execute the following code:

```
//First file
AccessToFiles::getInstance(3600)->addFiles(['document.pdf']);

//The second file
AccessToFiles::getInstance(300)->addFiles(['picture.jpg']);

```

In this part, we create two  *AccessToFiles*  objects - one to open access for 1 hour - the second to open access for 5 minutes. And then add the file to each object.

The  *AccessToFiles*  class always creates one for the access time, which means that if we do the following after the code above:

```
$af = AccessToFiles::getInstance(3600);

```

then the new object will not be created, but only the object created above will be returned for the files available for 1 hour.

To open file access for each instance, you must execute the  *allowFiles*  method:

```
AccessToFiles::getInstance(3600)->allowFiles();
AccessToFiles::getInstance(300)->allowFiles();

```

This method writes metadata about files (what kind of files, for how long, to whom ...) in the metadata store, by default it's Redis.

Now, if the same user accesses these files, they will be available to him, but after the elapsed time intervals (1 hour and 5 minutes respectively)  the carriage again turns into a pumpkin  the files will be unavailable again.

For the return of temporarily open files, the lua script for nginx responds, which can climb in Redis b to check whether there is data for the requested file, if there is, it gives the file.

How does the lua script determine the user?

When writing metadata about the file  *AccessToFiles*  uses the  **Finger print**  method, it tries to collect as much data about the current user so that its user can not be confused with anyone.

By default, only the session identifier is used for this, but HTTP headers can also be used in case the session is stolen.

 **Note:**  the lua script stored in the project will only work with the default identification set, i.e. if only the session identifier is used, minor enhancements will be required to expand the set.

[Documentation](docs_en)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 91.7% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10077243?v=4)[Aleksandr Avtomonov](/maintainers/avtomon)[@avtomon](https://github.com/avtomon)

---

Top Contributors

[![avtomon](https://avatars.githubusercontent.com/u/10077243?v=4)](https://github.com/avtomon "avtomon (11 commits)")[![qooiz](https://avatars.githubusercontent.com/u/53611552?v=4)](https://github.com/qooiz "qooiz (1 commits)")

### Embed Badge

![Health badge](/badges/scaleplan-access-to-files/health.svg)

```
[![Health](https://phpackages.com/badges/scaleplan-access-to-files/health.svg)](https://phpackages.com/packages/scaleplan-access-to-files)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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