Download the PHP package hadi-aghandeh/laravel-friendly-id without Composer

On this page you can find all versions of the php package hadi-aghandeh/laravel-friendly-id. 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-friendly-id

Laravel Friendly ID - Laravel String ID

Looking to convert the integer primary ID of your laravel model to an user friendly string?

This package enables you to generate string-based IDs for your models, without the need for a separate ID column. By default, Laravel uses integer IDs with MySQL, but in many cases, you may need unique string identifiers for your models. This package helps you implement these unique string IDs seamlessly.

1335684976 -> encode -> xxx-xxxx-xxx -> decode -> 1335684976

Here are some potential uses for having a string representation of IDs:

Installation

Install the package via Composer:

Configuration

After installing the package, publish the configuration file:

This will create a config/friendly-id.php file where you can customize the encoding settings.

Default Configuration

Encoders

BASEN

This changes the base of the integer to letters provided by FRIENDLY_ID_ALPHABET.

Example output with a length of 7:

SQIDS

This uses the well-known Sqids algorithm with its PHP package.

Example output with a length of 10:

WORDS

Sometimes, you may prefer your string to be a mix of words. These strings are easier to remember due to their use of vowels.

Usage

To start using friendly IDs in your Laravel models, simply use the FriendlyId trait in your model class.

Example

Add Trait to a Model

Encode and Decode Friendly IDs

You can now use the encodeFriendlyId method to generate a friendly string representation of the model's ID:

To decode a friendly ID back to the original integer ID, use the decodeFriendlyId method:

Query by Friendly ID

You can use the whereFriendlyId scope to query a model by its friendly ID:

Configuration Customization

To customize the encoding behavior, you can update your .env file with the following environment variables:

Exception Handling

The decodeFriendlyId method will return null if the provided friendly ID is invalid or cannot be decoded.

Testing

You can run tests for this package using PHPUnit:

License

This package is open-sourced software licensed under the MIT license.

Support

If this package helps you, please consider giving it a ⭐ on GitHub! Your support means a lot and helps to maintain this project.


All versions of laravel-friendly-id with dependencies

PHP Build Version
Package Version
Requires ext-bcmath Version *
php Version ^8.0
sqids/sqids Version ^0.4.1
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 hadi-aghandeh/laravel-friendly-id contains the following files

Loading the files please wait ....