Download the PHP package iak/keys without Composer
On this page you can find all versions of the php package iak/keys. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package keys
Short Description This is my package keys
License MIT
Homepage https://github.com/iak/keys
Informations about the package keys
Laravel Keys 🔑
The problem
We use string keys all across our application. We got keys for cache, rate limiting, queued jobs, sessions, broadcast channels, container aliases and so much more.
These keys can be hard to keep track of. You also need to remember what convention you used, sometimes build up keys from several dynamic values such as id's, and it's hard to get an overview of what keys are actually in use. It's also easy for typos to sneak in, as these are just strings.
This package solves this issue, by centralizing where your keys are defined, and give you a consistent and easy way to access them.
Features
- Configurable Key Templates: Define key formats in configuration files
- Dynamic Parameters: Define your dynamic values in the configuration, and the key class will fill them in for you
- Parameter Validation: Automatic validation of required parameters and detection of extra parameters
- Multiple Key Types: Built-in support for cache, queue, event, session, and many more key types
- Laravel Integration: Seamless integration with Laravel's configuration system
Installation
You can install the package via composer:
Then publish the config file with:
Usage
First, define your key templates in the configuration file:
Then access the keys using the Key helper class.
Built-in Key Types
The package comes with many built-in key types:
There are support for many different types of keys. For example: tag, lock, channel, broadcast, limit, middleware, view, translation, command, container, feature, notification, throttle, disk, policy, guard, schedule, tenant, experiment, test, mail, service, flash, alias, provider, raw, config
Dynamic Method Calling
You can also use dynamic method calling for custom key types:
Error Handling
The package validates parameters and provides helpful error messages:
Configuration
Key Template Format
Key templates use curly braces {} to define parameter placeholders:
Parameter Rules
- All parameters defined in the template must be provided
- Extra parameters not defined in the template will cause an exception
- The same parameter can be used multiple times in a template
- Parameters can be strings, numbers, or any scalar value
Testing
Credits
- Isak Berglind
- Erik Bäck
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of keys with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0