karmabunny / kb
Common KB utilities
Installs: 1 216
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 10
Forks: 0
Open Issues: 4
Requires
- php: ^7.2|^8
- symfony/polyfill-php73: *
- symfony/polyfill-php81: ^1.26
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.3
- dev-master
- 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/timezone-helpers
- 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/virtual-attributes
- dev-feat/rule-attributes
- dev-feat/hooks
- dev-feat/alias-refactor
- dev-backport/v1
This package is auto-updated.
Last update: 2024-11-22 03:05:53 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:^2
Code standard
Keep the dependencies to nil.
If you need them, then it doesn't belong in this library.
Must support php 7.0.
But feel free to slip in some ponyfills.
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 (like Copyable) 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.
As always, when deprecating + removing things always annotate your release tag. Imagine your life depends on getting it all in there. Is that a threat? Maybe.
Collections
Models! Models! Models!
Collections extends DataObject with some array-like, virtual, serializable stuff.
Some optional behavioural traits:
- UpdateStrictTrait
- UpdateTidyTrait
- UpdateVirtualTrait
- FieldsTrait
- CachedHelperTrait
Validators
Collection extensions:
- Doc Validator
- Rules Validator
Also the Validity class. Yay.
Loggable
Per-class logging utilities. Has logger forwarding. Kinda interesting.
Jobs
Generic type for crons and workers.
Reflect
Some useful reflection things.
Serialisation
- Json - normalised encode/decode with exceptions
- XML - now with templating
- Enc
- Url
Security
- secure random - bytes, string!
- hash password
- comparisons
Time
- utime, microtime as an integer
- time ago
- converting things between DateTime, DateTimeImmutable, DateTimeInterface
- date periods
Arrays
Non-standard or weakly supported things.
- array first
- array last
- fill w/ callback
- find w/ callback
- flatten!
- queries (aka
value()
) - create map
- normalise keys
- config loader!
The config loader is particular pleasant. It supports both traditional $config
and modern return [];
style configs. Combined with value()
you can recreate Kohana::config()
with ease.
Consts
- HttpStatus
- CountryNames
UUID
for v1, v4, v5 (the good ones)
Env
Environment loading from system or a config file.
Also isDocker()
- super handy.
FnUtils (Wrap)
Mostly related to array_map()
and array_filter()
.
CSV
- Importer
- Exporter
XML/Dom utils
- Parsing
- Validating
- XPath!
- 'expects'
URL
- Encode + decode
- URL builder
Shell utilities
- Safe cmd args
- Async + sync interfaces
CLI utilities
- text input
- masked input
- invisible input
- question - bool
- options - with key browsing