Download the PHP package channor/hashed-route-key without Composer

On this page you can find all versions of the php package channor/hashed-route-key. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hashed-route-key

Opaque Route Key

Deterministic, model-level opaque route keys for Laravel.

Replaces sequential integer IDs in URLs with compact, HMAC-verified route keys without storing anything extra in the database:

The result is deterministic and decodable. It is obfuscation with integrity checks, not encryption, not secrecy, and not authorization.

Note: This package is not a security boundary and does not replace authentication, authorization, or signed URLs.

The Eloquent trait keeps route-key generation and route binding on the model itself, while deriving distinct salts per model so the same integer ID produces different route keys across models by default.

Installation

Supported targets:

Laravel package discovery registers the service provider automatically. If your application disables package discovery, register it manually in bootstrap/providers.php:

Publish config when you need to customize behavior:

Quick Start

Add the trait to an Eloquent model with an integer primary key:

That is enough for route model binding and route() URL generation to use the opaque key. Serialization includes the computed route_key by default.

Upgrade To V2

Version 2.0.0 removes the deprecated hashed-route-key compatibility layer kept during v1.x. See the v2 upgrade guide for package, import, and config migration steps.

Configuration

Key Purpose Default
salt Base salt for all route-key derivations APP_KEY
append_route_key Auto-append route_key during serialization true
default_attribute_name Attribute name when appending route_key
min_payload_length Minimum encoded payload characters 3
check_length HMAC check tag characters (max 32) 4
offset_multiplier Shifts encoding space for low IDs 1
reserved_words Generated keys to avoid emitting []
reserved_words_case_sensitive Match manual reserved words by exact case only true
auto_reserve_model_names Reserve each model's lowercase singular and plural basename false
reserved_word_max_attempts Maximum candidate encodings, including the original 10

Once URLs are public, keep the effective salt and per-model strategy settings stable. Changing salt, salt suffix, payload length, check length, offset multiplier, reserved words, or reserved-word attempt settings can invalidate existing URLs or change future generated URLs for affected IDs.

Reserved Words

reserved_words prevents the codec from emitting route keys that collide with route paths such as create, edit, or new. The default list is empty because reserved route words are application-specific. With the default encoding settings, generated keys are at least 7 characters long, so shorter words cannot be emitted.

Manual reserved words are case-sensitive by default. Reserving account will not reserve aCcOuNt unless reserved_words_case_sensitive is false.

When auto_reserve_model_names is true, each model using the trait reserves its lowercase singular and plural class basename, for example account and accounts for Account. These model-name reservations are always matched case-insensitively.

If a generated key is reserved, the codec retries deterministic alternate encodings up to reserved_word_max_attempts. If every attempt collides, encoding throws a RuntimeException. Existing keys remain decodable even if you later reserve a word that was previously emitted.

Customization

Override strategy methods on a model when the defaults do not fit:

By default, the codec salt is:

routeKeySaltSuffix() defaults to snake_case(class_basename(Model::class)). Keep custom suffixes stable once URLs are public.

To customize the serialized attribute:

Contract Tests

Generate app-level stability tests before changing route-key settings:

Useful options:

Generated model tests pin strategy values and fixed route-key outputs. The reserved config test pins reserved-word settings.

Decode Failures

When an opaque key is invalid, tampered, wrong-model, or malformed:

Advanced Usage

If you need the lower-level codec directly, use the same model-specific salt strategy as the trait:

Capacity with the default base-62 alphabet:

Payload length Unique values
p=2 3,844
p=3 238,328
p=4 14,776,336

The payload starts at min_payload_length characters and adds characters as IDs grow beyond what the current length can represent. offset_multiplier shifts where these length boundaries fall.

Alternatives

vinkla/laravel-hashids and cybercog/laravel-optimus are relevant alternatives for Laravel applications that want obfuscated identifiers. Either may be a better fit depending on your needs and existing conventions.

Notes

Development Note

This package was developed with LLM assistance. Final design, review, and release decisions remain with the maintainer.


All versions of hashed-route-key with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/console Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package channor/hashed-route-key contains the following files

Loading the files please wait ...