Download the PHP package atldays/laravel-hashids without Composer

On this page you can find all versions of the php package atldays/laravel-hashids. 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 laravel-hashids

Laravel Hashids

Latest Version on Packagist Total Downloads CI

atldays/laravel-hashids helps Laravel apps use hash IDs as one clean, consistent flow.

Instead of handling encoding, decoding, validation, routing and API output in different places, the package keeps everything working together:

Under the hood, it is powered by hashids/hashids, while adding a Laravel-first developer experience around models, requests, validation and routing.

Your application can keep working with plain numeric values internally, while the outside world works with hash IDs in a predictable way.

Features

Installation

Install the package via Composer:

Publish the config file if you want to customize the defaults:

If you plan to contribute, please also read CONTRIBUTING.md.

Quick Start

Add HasHashId to your model:

Now you can:

Optional Model Contract

The HasHashId trait is enough for normal package usage. You do not need an interface just to generate hash IDs, resolve route bindings, validate request fields, or use the request helpers.

If you want a full typed contract for your own services, package integrations or PHPStan-friendly dynamic model classes, also implement HasHashIdModel:

This is useful when your own code accepts hash ID capable models through type hints:

Core Concept

The package is built around two layers:

  1. Internal application values Your models and database keep using numeric values.

  2. External application values Routes, requests, validation and serialized output can use hash IDs instead.

The hashid.enabled config option controls that external behavior.

When it is enabled:

When it is disabled:

That makes local debugging and gradual adoption much easier.

For a full request-response cycle, use getHashIdInput() when sending model identifiers to the client and findByHashIdInput() when accepting them back:

When hashid.enabled is true, getHashIdInput() returns a hash ID string. When it is false, it returns the plain numeric source value.

Basic Model Usage

Generate Hash IDs

getHashId() always returns the hashed representation when the model has a source value. getHashIdInput() follows hashid.enabled and is the safer choice for identifiers you send to a client and expect back in a request.

Find Models By Hash ID

Find Models By External Input

Use these helpers when the value comes from a request, route or another external input and should follow the hashid.enabled config:

When hashid.enabled is true, the input is decoded as a hash ID. When it is false, the input is resolved as a plain numeric value.

For symmetry, send values out with getHashIdInput():

Query Builder Helpers

Route Model Binding

If you want route model binding to work with hash IDs, add HasHashIdRouting:

Then standard Laravel route model binding works:

And route generation also uses the hash ID:

Validation

The package provides two rules:

Single Value

Arrays

The rules are nullable-friendly by design, so they work naturally with Laravel rules like required and nullable.

Validation messages are translated through the package translation files, and you can override them in your application the same way you override other Laravel package translations.

First publish the package translations:

Example:

Form Requests

For API-heavy projects, FormRequest integration is one of the most useful parts of the package.

It lets you accept hash IDs from the outside world, validate them, and then work with plain numeric values or resolved models inside your request and controllers.

Use the InteractsWithHashIds trait:

After validation:

Resolve Models From Request Fields

Dot Notation And Wildcards

The request layer supports nested fields:

And then:

Serialized Output

If you want your model to expose hash IDs in serialized output, add SerializesHashId:

When hashid.enabled is true, the source column used by the model is replaced in serialized output:

Instead of:

you get:

When hashid.enabled is false, serialization stays plain and returns numeric values.

Model Attributes

The package supports PHP attributes for model configuration.

Custom Source Column

Custom Salt

Salt From Class Name

Salt From Table Name

Trait-Level Defaults

Attributes can also live on traits, which is useful when you want shared behavior across multiple models.

Model-level attributes still take priority over trait-level attributes.

Legacy And Custom Salt Mapping

If you need to support old salts, old namespaces or legacy model mappings, use HashIdRegistry.

Example:

This is especially useful when you moved models between namespaces or repositories but still need old hash IDs to keep working.

Artisan Commands

The package provides model-aware commands:

These commands use the model's own hash ID configuration, including its salt logic.

Configuration

enabled

Controls the package's external behavior.

When enabled, the package uses hash IDs in:

When disabled, those integrations use plain numeric values instead.

salt

Default salt for the core HashId service.

length

The generated hash ID length.

alphabet

The alphabet passed to the underlying hashids/hashids encoder.

Core HashId Service

If you need the low-level service directly, you can use the HashId facade:

If you need a custom runtime configuration, you can create a configured HashId instance directly:

You can also override only the values you need:

Local Development

Install dependencies in the same Docker-based environment used by the project:

Run formatting and tests:


All versions of laravel-hashids with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
hashids/hashids Version ^5.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.93
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 atldays/laravel-hashids contains the following files

Loading the files please wait ...