PHPackages                             dsijak/sharefile - 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. [Security](/categories/security)
4. /
5. dsijak/sharefile

ActiveLibrary[Security](/categories/security)

dsijak/sharefile
================

Share files protected with access token.

v0.3(5y ago)012MITPHPPHP &gt;=7.0

Since Jun 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/damir-sijakovic/sharefile)[ Packagist](https://packagist.org/packages/dsijak/sharefile)[ RSS](/packages/dsijak-sharefile/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Sharefile
=========

[](#sharefile)

Share files protected with access token.
----------------------------------------

[](#share-files-protected-with-access-token)

Before use configure `vendor/dsijak/sharefile/project/Etc/config.php`.
Setting `DS_SF_MODE` mode to `production` will disable browser error log output.

### Install

[](#install)

```
        composer require dsijak/sharefile

```

### Usage

[](#usage)

First set directory with files in `config.php => DS_SF_FILE_DIR`. This
directory should be not accessable via url.

Acquire file item:

```
        $accessToken = $sharefile->acquireItem('vid.mp4');

```

File must exist and allowed filetype must be specified in `config.php`.
`acquireItem` method will store file, key and keyExpiration data into
sqlite/mariadb database. `acquireItem` method returns access token or key.
After this, you can send this key/token to whomever you want to have access
to acquired file.

Obtain file item:

```
        $sharefile->obtainItem('vid.mp4', 'f8b32a778acfaaaa');

```

This will generate new file with header inside your browser.
`obtainItem` method must be executed from new route or after redirected.
If key has expired, only text message will be generated.

### What is this useful for?

[](#what-is-this-useful-for)

For example, when you are selling digital items. When someone buys your
photography or ebook, you can send them file key. Key will be valid
only for amount of time you specify in the `config.php`.

For example, you can mail link `yoursite.com/obtainItem?filename=vid.mp4&key=f8b32a778acfaaaa`Then you can take file and key params:

```
        $sharefile->obtainItem($filename, $key);

```

This will generate acquired document or text document with message.

### Error messages

[](#error-messages)

Both `acquireItem` and `obtainItem` methods accept additional reference
argument to pass back error message.

```
        $errorMessage = '';
        $accessToken = $sharefile->acquireItem('ebook.pdf', $errorMessage);

        if (!$accessToken)
        {
            error_log($errorMessage);
        }

```

### Short usage example

[](#short-usage-example)

```
        use Sharefile\Sharefile;

        $sharefile = new Sharefile();
        $errorMessage = '';
        $accessToken = $sharefile->acquireItem('vid.mp4', $errorMessage);
        if (!$accessToken)
        {
            error_log($errorMessage);
        }

        $sharefile->obtainItem('vid.mp4', $accessToken);
        //renders file

```

### MariaDB Usage

[](#mariadb-usage)

Run this query:

```
        CREATE DATABASE ds_sharefile;
        CREATE USER 'ds_sharefile'@'localhost' IDENTIFIED BY 'ds_sharefile';
        GRANT ALL ON ds_sharefile.* TO 'ds_sharefile'@'localhost';
        USE ds_sharefile;

```

Edit: `vendor/dsijak/sharefile/project/Etc/config.php`.
Set `DS_SF_MODEL_TYPE` to `mariadb`.
Database user/pass are also set there.
To use existing PDO object, pass it to constructor together with database name:

```
        $sharefile = new Sharefile($pdoObj, 'myDatabaseName');

```

### Advanced methods

[](#advanced-methods)

These methods returns data/null or true/false.
You can get advanced methods through `advanced` property:

```
        $x = $sharefile->advanced->databaseCreatedAt($errorMessage);

```

#### Methods:

[](#methods)

**fileExists($filename, &amp;$eMessage=null)**
Checks if file exists.

**emptyDatabase(&amp;$eMessage=null)**
Removes all aquired items from database.

**databaseCreatedAt(&amp;$eMessage=null)**
Returns creation date.

**generateFileKey($filename, &amp;$eMessage=null)**
Generates key for filename and stores everything.

**deleteKey($key, &amp;$eMessage=null)**
Deletes key, if exists.

**getGeneratedFileKeyRecord($filename, $key, &amp;$eMessage=null)**
Returns key/filename, if exists.

**isKeyValid($filename, $key, &amp;$eMessage=null)**
Checks if key/token is valid.

**generateBase64ImageFile($filename, &amp;$eMessage=null)**
Generates html img element with base64 image. This is ment to be used with images.

**generateHeaderFile($filename)**
Generates file as HTTP respose.

**generateHeaderMessage($message)**
Generates text file as HTTP respose with $message.

### Have Fun

[](#have-fun)

`Developed and tested under 5.4.118-1-manjaro/xfce/docker/portainer`

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1898d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/125874756?v=4)[Deni Šijak](/maintainers/dsijak)[@dsijak](https://github.com/dsijak)

---

Top Contributors

[![damir-sijakovic](https://avatars.githubusercontent.com/u/50234352?v=4)](https://github.com/damir-sijakovic "damir-sijakovic (1 commits)")

---

Tags

filesharingphpsqlite

### Embed Badge

![Health badge](/badges/dsijak-sharefile/health.svg)

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

###  Alternatives

[phpids/phpids

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

791150.0k2](/packages/phpids-phpids)[paragonie/ecc

PHP Elliptic Curve Cryptography library

25866.3k44](/packages/paragonie-ecc)[nicobleiler/php-passphrase

Passphrase generator with Laravel integration, inspired by Bitwarden. Uses the EFF long word list by default with support for custom wordlists.

4912.6k](/packages/nicobleiler-php-passphrase)[dwgebler/encryption

Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.

317.5k](/packages/dwgebler-encryption)

PHPackages © 2026

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