PHPackages                             wad/securelink - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wad/securelink

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wad/securelink
==============

A lightweight PHP package to create temporary self-expiring links based on time or clicks.

04PHP

Since Jul 29Pushed 11mo agoCompare

[ Source](https://github.com/Github-Suriya/securelink)[ Packagist](https://packagist.org/packages/wad/securelink)[ RSS](/packages/wad-securelink/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

SecureLink
==========

[](#securelink)

**SecureLink** is a lightweight, framework-agnostic PHP package that allows you to create temporary, self-expiring links. These links can expire based on time or number of clicks, making it ideal for securely sharing sensitive content or granting temporary access.

---

Features
--------

[](#features)

- Generate **time-limited** links (expire after configurable minutes)
- Generate **click-limited** links (expire after a certain number of clicks)
- Automatic expiry handling with customizable messages
- Simple and lightweight, using file storage or adaptable to other storages
- Easy integration with any PHP project (no framework required)
- Optional audit logging (can be extended)
- Secure token generation using PHP’s `random_bytes()`

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Generating Time-Limited Link](#generating-time-limited-link)
    - [Generating Click-Limited Link](#generating-click-limited-link)
    - [Handling Link Access (Redirection)](#handling-link-access-redirection)
- [Configuration](#configuration)
- [Project Structure](#project-structure)
- [Advanced Usage](#advanced-usage)
- [License](#license)

---

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

[](#installation)

1. Clone or download this repository to your project folder.
2. Make sure your PHP version is 7.2+ (for `random_bytes()` support).
3. Set writable permissions to the `storage/` directory, as it stores link metadata.

**Installation USING composer**
-------------------------------

[](#installation-using-composer)

```
composer require wad/securelink:dev-main
```

If you want to use Composer autoloading:

```
composer dump-autoload
```

---

Usage
-----

[](#usage)

Below are basic usage examples of SecureLink using core PHP.

### Generating Time-Limited Link

[](#generating-time-limited-link)

```
require_once DIR . '/src/SecureLink.php';

// Initialize with storage folder path and secret key
$secureLink = new SecureLink(DIR . '/storage', 'your-secret-key');

// Create a link that expires in 30 minutes
$link = $secureLink->createTimeLink('https://example.com/secret-file.zip', 30);

echo "Your 30-minute temporary link: $link\n";
```

### Generating Click-Limited Link

[](#generating-click-limited-link)

```
require_once DIR . '/src/SecureLink.php';

$secureLink = new SecureLink(DIR . '/storage', 'your-secret-key');

// Create a link that expires after 5 clicks
$link = $secureLink->createClickLink('https://example.com/private-report.pdf', 5);

echo "Your 5-click temporary link: $link\n";
```

### Handling Link Access (Redirection)

[](#handling-link-access-redirection)

Create a `secure.php` file that handles link validation and redirects users accordingly:

```
require_once DIR . '/src/SecureLink.php';

$secureLink = new SecureLink(DIR . '/storage', 'your-secret-key');

$token = $_GET['token'] ?? '';

$url = $secureLink->resolve($token);

if ($url && !in_array($url, ['Link expired', null])) {
header("Location: $url");
exit;
} else {
echo "Link expired or invalid.";
}
```

---

Configuration
-------------

[](#configuration)

- **Storage Path:** The directory where link data (JSON files) are saved. Must be writable by your PHP process.
- **Secret Key:** Used internally for generating tokens securely (you can extend encryption if needed).
- **Base URL:** The package generates URLs pointing to your `secure.php` file. Update this URL in the `generateUrl()` method if your domain or path changes.

---

Project Structure
-----------------

[](#project-structure)

> securelink/
> |-- src/
> | |-- SecureLink.php # Core package class
> |-- storage/ # Stores link metadata files
> |-- secure.php # Link validation and redirector script
> |-- example.php # Example usage script
> |-- composer.json # Optional, for autoloading and package metadata
> |-- README.md # This file

---

Advanced Usage &amp; Extensions
-------------------------------

[](#advanced-usage--extensions)

- **Password Protection:** Extend the package to add password validation before redirect.
- **Audit Logging:** Add functionality to log link accesses to a file or DB.
- **Database Support:** Swap file storage with a database like SQLite or MySQL.
- **Framework Integrations:** Provide adapters/middleware for Laravel, Symfony, etc.
- **Email Notifications:** Notify users when links are created or accessed.
- **Encryption:** Secure URLs or link metadata with encryption for extra security.

If you want help implementing any of these, feel free to open an issue or reach out!

---

License
-------

[](#license)

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

---

Contact
-------

[](#contact)

Created by SuryaDev — Feel free to reach out for questions or suggestions!

---

**Happy coding with SecureLink! 🚀**

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/154968651?v=4)[Suriya Murugan](/maintainers/Github-Suriya)[@Github-Suriya](https://github.com/Github-Suriya)

---

Top Contributors

[![Github-Suriya](https://avatars.githubusercontent.com/u/154968651?v=4)](https://github.com/Github-Suriya "Github-Suriya (11 commits)")

### Embed Badge

![Health badge](/badges/wad-securelink/health.svg)

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

###  Alternatives

[tritum/repeatable-form-elements

Adds a new form element which allows the editor to create new container elements with any type fields in them. In the frontend, a user can create any number of new containers. This is an extension for TYPO3 CMS.

16111.0k](/packages/tritum-repeatable-form-elements)

PHPackages © 2026

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