Download the PHP package tiemsky/haskey without Composer

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

HasKey

The HasKey package provides a trait for Laravel Eloquent models to automatically generate unique keys based on the model's class name and a random string. The length of the class name substring and the random string length are configurable.

Features

Installation

1. Install the Package

In your Laravel project, add the package to your composer.json by requiring it:

2. Publish the Configuration (Optional)

To customize the length of the class name substring and the random string in the key, publish the package's configuration file:

This command will create a configuration file at config/haskey.php. Configuration

After publishing the configuration file, you can adjust the following settings in config/haskey.php:

return [ 'substring_length' => 3, // Default length of the class name prefix (customizable) 'key_length' => 10, // Default length for the random string part of the key (customizable) ];

Default Values

substring_length: Defines the length of the prefix derived from the model’s class name. Defaults to 3.
key_length: Sets the length of the random string appended to the key. Defaults to 10.

Usage

Add the HasKey Trait to Your Model

To use the HasKey trait, simply add it to any Eloquent model where you want a unique key to be generated.

Creating a Model Instance

When a new model instance is created, the HasKey trait will automatically generate a unique key in the format:

{classprefix}{random_string}

class_prefix: The first few characters of the class name, as defined by substring_length.
random_string: A random string, as defined by key_length.

Example

For a model named Product, with the default configuration:

substring_length of 3
key_length of 10

The generated key might look like: pro_aBc123XyZq.

Development

1. Testing

To ensure that your package works as expected, you can write tests in the tests/ directory of your package (create it if it doesn't exist).

2. Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue if you find bugs or have suggestions. License

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


All versions of haskey with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^11.31
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 tiemsky/haskey contains the following files

Loading the files please wait ....