karmabunny / kb
Common KB utilities
Requires
- php: ^8.2
- karmabunny/interfaces: ^2
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v5.68.53
- v5.67.53
- v5.66.53
- v5.66.52
- v5.65.52
- v4.x-dev
- v4.65.52
- v4.65.51
- v4.64.51
- v4.63.51
- v4.63.50
- v4.63.49
- v4.62.49
- v4.62.48
- v4.61.48
- v4.61.47
- v4.61.46
- v4.61.45
- v4.61.44
- v4.61.43
- v4.61.42
- v4.60.41
- v4.60.40
- v4.59.40
- v4.58.40
- v4.58.39
- v4.58.38
- v3.x-dev
- v3.59.38
- v3.58.38
- v3.58.37
- v3.58.36
- v3.58.35
- v3.57.35
- v3.56.35
- v3.56.34
- v3.56.33
- v3.55.33
- v3.55.32
- v3.54.32
- v3.53.32
- v3.52.32
- v3.51.32
- v3.50.32
- v3.50.31
- v3.50.29
- v3.49.29
- v3.49.28
- v3.49.27
- v3.48.27
- v3.47.27
- v3.46.27
- v3.45.27
- v3.45.26
- v3.44.26
- v3.43.26
- v3.42.26
- v3.42.25
- v3.41.25
- v3.41.24
- v3.41.23
- v3.40.22
- v3.39.22
- v3.38.22
- v3.38.21
- v3.37.21
- v3.36.21
- v2.36.21
- v2.35.21
- v2.35.20
- v2.34.20
- v2.34.19
- v2.33.19
- v2.33.18
- v2.32.18
- v2.31.18
- v2.30.18
- v2.30.17
- v2.30.16
- v2.29.15
- v2.28.15
- v2.28.14
- v2.27.14
- v2.26.14
- v2.25.14
- v2.24.14
- v2.23.14
- v2.22.14
- v2.21.14
- v2.20.14
- v2.19.14
- v2.18.14
- v2.18.13
- v2.18.12
- v2.17.12
- v2.16.12
- v2.16.11
- v2.16.10
- v2.15.10
- v2.15.9
- v2.14.9
- v2.13.8
- v2.12.7
- v2.12.6
- v2.11.5
- v2.11.4
- v2.11.3
- v2.10.3
- v2.9.2
- v2.8.2
- v2.8.1
- v2.7.1
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- v0.1.1
- 0.1
- dev-feat/php8
- dev-feat/virtual-attributes
- dev-feat/singleton-trait
- dev-feat/interfaces
- dev-fix/encrypt-config-cache
- dev-feat/time-month-year-opts
- dev-feat/to-json-trait
- dev-feat/arrayable-filters
- dev-feat/validation-labels
- dev-feat/upgrade-tags
- dev-feat/rule-attributes
- dev-feat/hooks
- dev-feat/alias-refactor
- dev-backport/v1
This package is auto-updated.
Last update: 2026-09-10 04:05:47 UTC
README
Just a big bunch of your favourite utilities.
Most of these have been repurposed from Sprout.
Add more if you please.
Usage
Pin it loosely the latest major version.
composer require karmabunny/kb:^5
Code standard
Keep the dependencies to nil.
If you need them, then it doesn't belong in this library.
Add the damn tests.
Like, even just the happy-cases.
Running tests
Create tests whenever you can.
Run them like this: composer test.
Deprecation path
Mistakes happen and sometimes you realise that your naming convention is terrible.
So when removing things, first mark them as @deprecated this should signal to anyone using the code that it'll disappear in the next major version. Like even if we forget and we're still lugging a bunch of stuff in the compat folder.
As always, when deprecating + removing things always annotate your release tag.
List of Utilities
Arrays
Lots of bits.
- array first
- array last
- fill w/ callback
- find w/ callback
- flatten
- queries (aka
value()) - create map
- normalise keys
- config loader
- recursive helpers
Output Buffer
Object interface for ob() methods.
CLI utilities
- text input
- masked input
- invisible input
- question - bool
- options - with key browsing
- colours
Collections
Models! Models! Models!
Collections extends DataObject with some array-like, virtual, serializable stuff.
This encapsulates a body of other interfaces and helpers:
- Configurable
- Arrayables
- Dirty Objects
Some optional behavioural traits:
- UpdateStrictTrait
- UpdateTidyTrait
- UpdateVirtualTrait
- FieldsTrait
- CachedHelperTrait
- DocValidatorTrait
- RulesValidatorTrait
CLI utilities
- text input
- masked input
- invisible input
- question - bool
- options - with key browsing
- colours
Config
Helper to load configs. Extend it and configure your paths. Supports config flattening.
Country Names
Using php-intl to convert between ISO codes and names.
Country Zones
Lookup countries from a timezone, or zones within a country.
CSV
- Importer
- Exporter
DocType
Parse types from doc comments.
Encrypt
Configurable openssl based text encryption.
Env
Environment loading from system or a config file.
Also isContainer() - super handy.
Event
Object event system.
Generate
Simple helpers to serialise arrays into PHP code.
HttpStatus
Some consts. Some strings.
Inflector
Converting plurals. English only - for code patterns. Go find some ICU if you want pluralisation in your UI.
Job
Generic type for crons and workers.
Json and Javascript
Helpers to encode JSON objects and embed Javascript.
Loggable and Log
Per-class logging utilities. Log forwarding and filtering.
Reflect
Some useful reflection things.
Kind of a mess actually.
Secrets
Masking or removing known secrets by identifing patterns.
Serialisation
- Json - normalised encode/decode with exceptions
- XML - now with templating
- Enc
- Url
Security
- secure random - bytes, string!
- hash password
- comparisons
Shell
- Safe cmd args
- Async + sync interfaces
Proc wrapper. But actually don't use this.
Sortable
Sorting lists of objects w/ Array::sort helpers.
Text
Multibyte helpers, normalisers, masking PII data.
Time
- utime, microtime as an integer
- time ago
- converting things between DateTime, DateTimeImmutable, DateTimeInterface
- interval helpers
- date periods
- offset formatter
- week/month/years as options, grids
- relative helper
TimeZones
Conversion between Windows and IANA timezones.
Url
Encode, decode, parser, builder.
UUID
for v1, v4, v5 (the good ones)
Validators
Collection extensions:
- Doc Validator
- Rules Validator (static, using Validity)
- Rules Validator (class, using RuleInterface)
XML/Dom utils
- Parsing
- Validating
- XPath
- conditionals
- 'expects'