chillerlan / php-standard-utilities
A collection of reusable multi-purpose functions for PHP libraries.
Fund package maintenance!
Ko-Fi
Requires
- php: ^8.1
- ext-json: *
- ext-mbstring: *
- ext-sodium: *
Requires (Dev)
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^1.12
- phpstan/phpstan-deprecation-rules: ^1.2
- phpunit/phpunit: ^10.5
- slevomat/coding-standard: ^8.15
- squizlabs/php_codesniffer: ^3.11
README
A collection of reusable multi-purpose functions for PHP libraries.
Overview
Features
This library features some common functions to reduce overall duplication and avoid certain ugly workarounds (looking at you, phpstan...).
Requirements
- PHP 8.1+
- extensions:
json
,mbstring
,sodium
- extensions:
API
Arr
(we can't use array
as class name because reasons)
Crypto
The Crypto
class defines the following public constants:
pre-defined character maps for use with Crypto::randomString()
as $keyspace
:
NUMERIC
: numbers 0-9ASCII_LOWER
: ASCII a-zASCII_UPPER
: ASCII A-ZASCII_SYMBOL
: ASCII printable symbols!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~
HEXADECIMAL
: numbers 0-9 + ASCII a-fASCII_ALPHANUM
: numbers 0-9 + ASCII a-z + A-ZASCII_PRINTABLE
: numbers 0-9 + ASCII a-z + A-Z + printable symbolsASCII_COMMON_PW
: ASCII printable minus a few troublemaker symbols!#$%&()*+,-./:;<=>?@[]~_|
output and input $format
for the functions Crypto::encrypt()
and Crypto::decrypt()
, respectively:
ENCRYPT_FORMAT_BINARY
: raw binaryENCRYPT_FORMAT_BASE64
: mime base64ENCRYPT_FORMAT_HEX
: hexadecimal
Directory
File
Str
(see Arr
)
Disclaimer
Use at your own risk!