Download the PHP package red-explosion/laravel-sqids without Composer

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

Laravel Sqids

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Sqids (pronounced "squids") allows you to easily generate Stripe/YouTube looking IDs for your Laravel models. These IDs are short and are guaranteed to be Collision free.

For more information on Sqids, we recommend checking out the official Sqids (formerly Hashids) website: https://sqids.org.

Installation

To get started, install Laravel Sqids via the Composer package manager:

Next, you should publish the Sqids configuration file using the vendor:publish artisan command. The sqids configuration file will be placed in your applications config directory:

Usage

Using Sqids

To use Laravel Sqids, simply add the RedExplosion\Sqids\Concerns\HasSqids trait to your model:

You will now be able to access the Sqid for the model, by calling the sqid attribute:

The result of $sqid will be encoded value of the models primary key along with the model prefix.

[!Tip] Only integers can be encoded, and therefore we recommend using this package in conjunction with auto incrementing IDs.

If you would like to set a custom prefix for the model, you can override it by setting a $sqidPrefix property value on your model like so:

Builder Mixins

Laravel Sqids provides a number of Eloquent builder mixins to make working with Sqids seamless.

Find by Sqid

To find a model by a given Sqid, you can use the findBySqid method:

If the model doesn't exist, null will be returned. However, if you would like to throw an exception, you can use the findBySqidOrFail method instead which will throw a ModelNotFoundException when a model can't be found:

Where Sqid

To add a where clause to your query, you can use the whereSqid method:

This will retrieve all users where the Sqid/primary key matches the given value.

Where Sqid in

To get all models where the Sqid is in a given array, you can use the whereSqidIn method:

This will return all users where the id is in the array of decoded Sqids.

Where Sqid not in

To get all models where the Sqid is not in a given array, you can use the whereSqidNotIn method:

This will return all users where the id is not in the array of decoded Sqids.

Route model binding

Laravel Sqids supports route model binding out of the box. Simply create a route as you normally would and we'll take care of the rest:

Finding a model from a Sqid

One of the most powerful features of Laravel Sqids is being able to resolve a model instance from a given Sqid. This could be incredibly powerful when searching models across your application.

When we run the following, $user will be an instance of the User model for the given Sqid. If no model could be found, then null will be returned.

if you would like to throw an exception instead, you can use the findOrFail method which will throw an instance of the ModelNotFoundException:

[!IMPORTANT] In order to use this feature, you must use prefixes for your Sqids.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover a security vulnerability, please send an e-mail to Ben Sherred via [email protected]. All security vulnerabilities will be promptly addressed.

Credits

License

Laravel Sqids is open-sourced software licensed under the MIT license.


All versions of laravel-sqids with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.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 red-explosion/laravel-sqids contains the following files

Loading the files please wait ....