Download the PHP package mordilion/mutils without Composer

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

MUtils

Latest Version PHP Version

A PHP utility library providing helpful array, string, bitwise, and reflection functions — plus stable-sort and string backports so PHP 7.1+ projects can use PHP 8.0+ behaviour today.

Dual API: Every function is available as a namespaced function (MUtils\Arrays\sort()) and as a static method (MUtils\Arrays::sort()). Use whichever style fits your codebase.

Table of Contents

Installation

Quick Start


Arrays

Array sorting with stable-sort guarantees (PHP 8.0+ backport) and utility functions for grouping, moving, and prefix operations.

Sorting (PHP 8.0+ Backports)

On PHP 8.0+ these pass through to the native implementation. On PHP < 8.0 they use a Schwartzian transform to guarantee stable sorting — equal elements retain their original order.

Note: The backport implementation is slower than native sorting. On PHP 8.0+ there is no performance penalty.

Function Static Method Description
sort(array &$array, int $flags = SORT_REGULAR): bool Arrays::sort() Sort array by values
rsort(array &$array, int $flags = SORT_REGULAR): bool Arrays::reverseSort() Reverse sort by values
asort(array &$array, int $flags = SORT_REGULAR): bool Arrays::associativeSort() Sort maintaining key association
arsort(array &$array, int $flags = SORT_REGULAR): bool Arrays::associativeReverseSort() Reverse sort maintaining key association
ksort(array &$array, int $flags = SORT_REGULAR): bool Arrays::keySort() Sort by keys
krsort(array &$array, int $flags = SORT_REGULAR): bool Arrays::keyReverseSort() Reverse sort by keys
natsort(array &$array): bool Arrays::naturalSort() Natural order sort
natcasesort(array &$array): bool Arrays::naturalCaseInsensitiveSort() Case-insensitive natural order sort
usort(array &$array, callable $callback): bool Arrays::userSort() User-defined sort
uasort(array &$array, callable $callback): bool Arrays::userAssociativeSort() User-defined sort maintaining key association
uksort(array &$array, callable $callback): bool Arrays::userKeySort() User-defined sort by keys

Utility Functions

array_group_by(array $array, bool $preserveKeys, $column, ...$columns): array

Static: Arrays::groupBy()

Groups array elements by a column key, object property, or callable. Pass additional $column arguments for nested grouping.

The $column parameter accepts:

Throws: InvalidArgumentException if $column is not a string, integer, float, or callable.


array_move_element(array &$array, int $fromIndex, int $toIndex): void

Static: Arrays::moveElement()

Moves an element from one position to another within an indexed array.

Throws: OutOfBoundsException if either index is out of range or the array is empty.


array_prefix_add(array $array, string $prefix, int $options = ARRAY_PREFIX_KEY): array

Static: Arrays::addPrefix()

Adds a prefix to array keys or values.


array_prefix_remove(array $array, string $prefix, int $options = ARRAY_PREFIX_KEY): array

Static: Arrays::removePrefix()

Removes a prefix from array keys or values. Keys/values that do not start with the prefix are left unchanged.


Prefix Constants

Constant Value Effect
ARRAY_PREFIX_KEY 1 Apply prefix operation to keys (default)
ARRAY_PREFIX_VALUE 2 Apply prefix operation to values

Since these are bitmask values, you can combine them: ARRAY_PREFIX_KEY | ARRAY_PREFIX_VALUE (= 3) applies the operation to both keys and values.


array_compare_flags($a, $b, int $flags): int

Static: Arrays::compareFlags()

Compares two values using PHP sort flag semantics. Primarily used internally by the stable-sort backport, but available as a public API.

Supported flags: SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_STRING | SORT_FLAG_CASE, SORT_NATURAL, SORT_NATURAL | SORT_FLAG_CASE, SORT_LOCALE_STRING.


Bits

Bitwise utility functions for working with sets of bit flags.

Function Static Method Description
bit_set(int $set, int $bit): int Bits::set() Set a bit in the given integer
bit_isset(int $set, int $bit): bool Bits::isset() Check if a bit is set
bit_unset(int $set, int $bit): int Bits::unset() Unset a bit in the given integer

Strings

PHP 8.0+ string function backports. On PHP 8.0+ these pass through to the native implementation. On PHP < 8.0 they use mb_* functions as the implementation.

Note: On PHP < 8.0, the mbstring extension is required.

Function Static Method Description
str_contains(string $haystack, string $needle): bool Strings::contains() Check if string contains substring
str_starts_with(string $haystack, string $needle): bool Strings::startsWith() Check if string starts with substring
str_ends_with(string $haystack, string $needle): bool Strings::endsWith() Check if string ends with substring

Objects

Reflection utility functions that traverse the class inheritance chain. Unlike PHP's built-in ReflectionClass::getMethod() and ReflectionClass::getProperty(), these functions walk up through parent classes to find methods and properties defined anywhere in the hierarchy.

Function Static Method Description
get_reflection_class($objectOrClass): ?ReflectionClass Objects::getReflectionClass() Get ReflectionClass from object, class name, or ReflectionClass
get_reflection_method($objectOrClass, string $name): ?ReflectionMethod Objects::getReflectionMethod() Find method in class or its parents
get_reflection_property($objectOrClass, string $name): ?ReflectionProperty Objects::getReflectionProperty() Find property in class or its parents

All functions accept an object instance, a class name string, or a ReflectionClass instance as the first parameter. Returns null if the target is not found (or if null is passed).

Throws: InvalidArgumentException if the first argument is not an object, string, or null. get_reflection_class may also throw ReflectionException if the class does not exist.


PHP Version Compatibility

Feature PHP >= 8.0 PHP 7.1 - 7.4
Stable sorting Native pass-through Schwartzian transform (slower)
String functions (str_contains, etc.) Native pass-through mb_* implementation (requires mbstring)
Utility functions (bits, objects, arrays) Full support Full support

Development

License

MIT


All versions of mutils with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1 || >=8.0
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 mordilion/mutils contains the following files

Loading the files please wait ...