PHPackages                             intelfric/laravel-encrypted-route - 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. intelfric/laravel-encrypted-route

ActiveLibrary[Security](/categories/security)

intelfric/laravel-encrypted-route
=================================

A Laravel package that encrypts full route URLs for enhanced security and obfuscation

1.2.0(11mo ago)05MITPHPPHP ^8.1

Since Jul 24Pushed 11mo agoCompare

[ Source](https://github.com/INTELFRIC/laravel-encrypted-route)[ Packagist](https://packagist.org/packages/intelfric/laravel-encrypted-route)[ Docs](https://github.com/intelfric/laravel-encrypted-route)[ RSS](/packages/intelfric-laravel-encrypted-route/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (7)Versions (4)Used By (0)

Laravel Encrypted Route
=======================

[](#laravel-encrypted-route)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a06b7d151ac2e19e131ead27190809e99eb03378d55e603608c7f6de9df0bf61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74656c667269632f6c61726176656c2d656e637279707465642d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/intelfric/laravel-encrypted-route)[![Total Downloads](https://camo.githubusercontent.com/3011339697d4f1e90e8f90ea91f0c3913a4d116ccf11468b6bc31f68d085c762/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e74656c667269632f6c61726176656c2d656e637279707465642d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/intelfric/laravel-encrypted-route)

A Laravel package that encrypts full route URLs for enhanced security and obfuscation. Transform your readable URLs into encrypted, random-looking paths that maintain full functionality while hiding your application's structure.

Features
--------

[](#features)

- 🔐 **Full URL Encryption**: Encrypt route names and parameters into unreadable strings
- ⏰ **Time-based Expiry**: Optional URL expiration with configurable TTL
- 🔄 **Flexible Routing**: Choose between redirects or internal dispatch
- 🎯 **Route Validation**: Ensure only valid routes can be encrypted
- 🚀 **Performance**: Optional caching for decrypted routes
- 🛡️ **Security**: Built on Laravel's encryption system
- 📦 **Easy Integration**: Simple helper functions and Facade support

Example
-------

[](#example)

Transform this:

```
https://myapp.com/user/dashboard/123

```

Into this:

```
https://myapp.com/encrypted/eyJpdiI6InNxQVJzOUg4...

```

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

[](#installation)

Install the package via Composer:

```
composer require intelfric/laravel-encrypted-route
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

Laravel 5.5+ automatically discovers the package. For older versions, add the service provider:

```
// config/app.php
'providers' => [
    // ...
    Intelfric\EncryptedRoute\EncryptedRouteServiceProvider::class,
],

'aliases' => [
    // ...
    'EncryptedUrl' => Intelfric\EncryptedRoute\Facades\EncryptedUrl::class,
],
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=encrypted-route-config
```

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

[](#configuration)

The configuration file `config/encryptedroute.php` provides several options:

```
return [
    // Route prefix for encrypted URLs
    'route_prefix' => 'encrypted',

    // Whether to redirect to original URL or dispatch internally
    'redirect_to_original' => false,

    // Default expiry time in minutes (null = no expiry)
    'default_expiry_minutes' => null,

    // Middleware applied to encrypted routes
    'middleware' => ['web'],

    // Cache decrypted routes for performance
    'cache_decrypted_routes' => false,

    // Cache TTL in seconds
    'cache_ttl' => 300,

    // Allowed routes (empty = all allowed)
    'allowed_routes' => [],

    // Routes that cannot be encrypted
    'excluded_routes' => [
        'login', 'logout', 'register'
    ],
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

#### Using Helper Function

[](#using-helper-function)

```
// Generate encrypted URL
$encryptedUrl = encrypted_url('user.dashboard', ['id' => 123]);

// In Blade templates

    View Profile

```

#### Using Facade

[](#using-facade)

```
use Intelfric\EncryptedRoute\Facades\EncryptedUrl;

$url = EncryptedUrl::generate('admin.settings', ['tab' => 'security']);
```

#### Using Route Macro

[](#using-route-macro)

```
// In your routes or controllers
$url = Route::encryptedUrl('api.data', ['format' => 'json']);
```

### Advanced Usage

[](#advanced-usage)

#### Temporary URLs with Expiry

[](#temporary-urls-with-expiry)

```
// URL expires in 60 minutes
$temporaryUrl = encrypted_url_with_expiry('download.file', 60, ['file' => 'document.pdf']);

// URL expires at specific time
$expiry = now()->addHours(2);
$temporaryUrl = temporary_encrypted_url('admin.report', $expiry, ['type' => 'sales']);
```

#### URL Validation

[](#url-validation)

```
// Check if encrypted path is valid
if (is_valid_encrypted_url($encryptedPath)) {
    // URL is valid and not expired
    echo "Valid URL";
}
```

#### Using the Facade for Complex Operations

[](#using-the-facade-for-complex-operations)

```
use Intelfric\EncryptedRoute\Facades\EncryptedUrl;

// Generate with custom expiry
$url = EncryptedUrl::generateWithExpiry('user.dashboard', ['id' => 1], 30);

// Generate temporary URL
$expiry = now()->addDay();
$url = EncryptedUrl::temporary('download.report', $expiry, ['format' => 'pdf']);

// Validate encrypted path
$isValid = EncryptedUrl::isValid($encryptedPath);
```

How It Works
------------

[](#how-it-works)

1. **URL Generation**: When you call `encrypted_url()`, the package:

    - Validates the route exists
    - Encrypts the route name and parameters using Laravel's encryption
    - Generates a URL with the encrypted data
2. **URL Resolution**: When a user visits an encrypted URL:

    - The package decrypts the path
    - Validates the route and checks expiry
    - Either redirects to the original route or dispatches it internally
3. **Security**: All encryption uses Laravel's built-in encryption system, ensuring your URLs are secure and tamper-proof.

Configuration Options
---------------------

[](#configuration-options)

### Route Behavior

[](#route-behavior)

Control how encrypted routes are handled:

```
// Redirect to original URL (user sees original URL)
'redirect_to_original' => true,

// Dispatch internally (user stays on encrypted URL)
'redirect_to_original' => false,
```

### URL Expiry

[](#url-expiry)

Set default expiry for all encrypted URLs:

```
// URLs expire after 1 hour by default
'default_expiry_minutes' => 60,

// No default expiry
'default_expiry_minutes' => null,
```

### Route Restrictions

[](#route-restrictions)

Control which routes can be encrypted:

```
// Only allow specific routes
'allowed_routes' => [
    'user.dashboard',
    'admin.panel',
],

// Prevent specific routes from being encrypted
'excluded_routes' => [
    'login',
    'register',
    'password.reset',
],
```

### Performance

[](#performance)

Enable caching for better performance:

```
'cache_decrypted_routes' => true,
'cache_ttl' => 300, // 5 minutes
```

Environment Variables
---------------------

[](#environment-variables)

You can configure the package using environment variables:

```
ENCRYPTED_ROUTE_PREFIX=secure
ENCRYPTED_ROUTE_REDIRECT=false
ENCRYPTED_ROUTE_EXPIRY=60
ENCRYPTED_ROUTE_CACHE=true
ENCRYPTED_ROUTE_CACHE_TTL=300
```

Use Cases
---------

[](#use-cases)

### 1. Admin Panel Security

[](#1-admin-panel-security)

Hide admin routes from being easily discovered:

```
$adminUrl = encrypted_url('admin.users.index');
// Generates: /encrypted/eyJpdiI6... instead of /admin/users
```

### 2. Temporary File Downloads

[](#2-temporary-file-downloads)

Create expiring download links:

```
$downloadUrl = encrypted_url_with_expiry('file.download', 30, ['file' => 'secret.pdf']);
```

### 3. Email Links

[](#3-email-links)

Generate secure links for emails:

```
$emailVerifyUrl = temporary_encrypted_url(
    'email.verify',
    now()->addDay(),
    ['token' => $token]
);
```

### 4. API Endpoints

[](#4-api-endpoints)

Obfuscate API endpoint structures:

```
$apiUrl = encrypted_url('api.user.data', ['user' => $userId, 'format' => 'json']);
```

Error Handling
--------------

[](#error-handling)

The package handles various error scenarios:

- **Invalid encrypted data**: Returns 404
- **Non-existent routes**: Returns 404
- **Expired URLs**: Returns 404
- **Excluded routes**: Throws `InvalidArgumentException`

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

[](#requirements)

- PHP 8.1+
- Laravel 9.0+

Testing
-------

[](#testing)

The package includes comprehensive tests. To run them:

```
composer test
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Security
--------

[](#security)

If you discover any security vulnerabilities, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- **Dr Msigwa** -
- **Intelfric Tech** - [intelfric.com](https://intelfric.com)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

---

Made with ❤️ by [Intelfric Tech](https://intelfric.com)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance51

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~0 days

Total

3

Last Release

346d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.2.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/80386833?v=4)[Dr. Constantino Msigwa](/maintainers/Constantino2019-et)[@Constantino2019-et](https://github.com/Constantino2019-et)

---

Top Contributors

[![Constantino2019-et](https://avatars.githubusercontent.com/u/80386833?v=4)](https://github.com/Constantino2019-et "Constantino2019-et (4 commits)")

---

Tags

phplaravelroutessecurityencryptionlaravel-packageobfuscationurl-encryption

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/intelfric-laravel-encrypted-route/health.svg)

```
[![Health](https://phpackages.com/badges/intelfric-laravel-encrypted-route/health.svg)](https://phpackages.com/packages/intelfric-laravel-encrypted-route)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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