PHPackages                             mcmatters/laravel-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mcmatters/laravel-helpers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mcmatters/laravel-helpers
=========================

Laravel helpers

v3.2.1(3mo ago)612.5k31MITPHPPHP &gt;=8.0CI failing

Since Apr 7Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/MCMatters/laravel-helpers)[ Packagist](https://packagist.org/packages/mcmatters/laravel-helpers)[ RSS](/packages/mcmatters-laravel-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (43)Used By (1)

Laravel Helpers
===============

[](#laravel-helpers)

[![Latest Stable Version](https://camo.githubusercontent.com/81b7a584ab478da980fe0f879b2ce94953116aab1edf8ef149b5b0cb5b53d6d0/68747470733a2f2f706f7365722e707567782e6f72672f6d636d6174746572732f6c61726176656c2d68656c706572732f762f737461626c65)](https://packagist.org/packages/mcmatters/laravel-helpers)[![Total Downloads](https://camo.githubusercontent.com/cdf4f31b22da190d5b5a8dc6eb9518ca805f85c697a04931e72e7950679e0de3/68747470733a2f2f706f7365722e707567782e6f72672f6d636d6174746572732f6c61726176656c2d68656c706572732f646f776e6c6f616473)](https://packagist.org/packages/mcmatters/laravel-helpers)

Installation
------------

[](#installation)

`composer require mcmatters/laravel-helpers`

Then run the command

```
php artisan vendor:publish --provider="\McMatters\Helpers\ServiceProvider"
```

If you prefer manual installation, then add to `config/app.php` into `providers` section next line:

```
'providers' => [
    McMatters\Helpers\ServiceProvider::class,
],
```

Otherwise it will be autodiscovered.

Configuration
-------------

[](#configuration)

Since `v2.0`, you can disable all helper functions and use helper classes, if you prefer to use helper functions, you can choose what exactly section do you want to use (`array`, `dev`, `string`, etc)

Functions
---------

[](#functions)

- [Arrays](#arrays)
- [Artisan](#artisan)
- [Class](#class)
- [Database](#database)
- [Dev](#dev)
- [Env](#env)
- [Math](#math)
- [Model](#model)
- [Request](#request)
- [Server](#server)
- [String](#string)
- [Type](#type)
- [Url](#url)

### Arrays

[](#arrays)

#### `array_first_key(array $array)`

[](#array_first_keyarray-array)

The `array_first_key` function returns first key from the given array.

#### `array_has_with_wildcard(array $array, string $keys, bool $searchWithSegment)`

[](#array_has_with_wildcardarray-array-string-keys-bool-searchwithsegment)

The `array_has_with_wildcard` is analogue of function `array_has` with ability to search with wildcard. Also it can search keys with dots (i.e. when you want to get some data from multiple field when validation is failed).

#### `array_key_by(array $array, string $key)`

[](#array_key_byarray-array-string-key)

The `array_key_by` function returns a new associative array grouped by `$key`.

#### `array_contains(array $array, string $needle, bool $byKey = false)`

[](#array_containsarray-array-string-needle-bool-bykey--false)

The `array_contains` function returns true if array contains given `$needle`. You can also search by array keys. This function searches only in first level of array.

#### `array_has_only_int_keys(array $array)`

[](#array_has_only_int_keysarray-array)

The `array_has_only_int_keys` function checks whether keys of given array as integer or not.

#### `shuffle_assoc(array $array)`

[](#shuffle_assocarray-array)

The `shuffle_assoc` function works like basic `shuffle` but with key preserving.

#### `array_change_key_case_recursive(array $array, int $case = CASE_LOWER)`

[](#array_change_key_case_recursivearray-array-int-case--case_lower)

The `array_change_key_case_recursive` function works like `array_change_key_case` except that it works recursively.

### Artisan

[](#artisan)

#### `get_php_path()`

[](#get_php_path)

The `get_php_path` function returns path to executable `php`.

#### `get_artisan()`

[](#get_artisan)

The `get_artisan` function return path to executable `artisan`.

#### `run_background_command(string $command, array $parameters = [])`

[](#run_background_commandstring-command-array-parameters--)

The `run_background_command` function runs the given command in background.

### Class

[](#class)

#### `get_class_constants($class)`

[](#get_class_constantsclass)

The `get_class_constants` function returns an array with all class constants.

#### `get_class_constants_start_with($class, string $string)`

[](#get_class_constants_start_withclass-string-string)

The `get_class_constants_start_with` function returns an array with constants which start with passed string.

### Database

[](#database)

#### `compile_sql_query($sql, array $bindings = null)`

[](#compile_sql_querysql-array-bindings--null)

The `compile_sql_query` function replaces all placeholders given bindings.

#### `get_all_tables(bool $withColumns = true, string $connection = null)`

[](#get_all_tablesbool-withcolumns--true-string-connection--null)

The `get_all_tables` function returns the list all tables with their columns.

#### `search_entire_database(string $keyword, string $connection = null)`

[](#search_entire_databasestring-keyword-string-connection--null)

The `search_entire_database` function searches entire database. It works only with MySQL and SQL drivers.

#### `has_query_join_with($query, string $with)`

[](#has_query_join_withquery-string-with)

The `has_query_join_with` function determines whether query has a joined table.

Dev
---

[](#dev)

#### `ddq($query, bool $die = false)`

[](#ddqquery-bool-die--false)

The `ddq` is analogue of function `dd`, but uses only for database queries.

#### `dump($value, bool $output = false)`

[](#dumpvalue-bool-output--false)

The `dump` is analogue of function `dd`, but without stopping the php script execution.

### Env

[](#env)

#### `is_production_environment()`

[](#is_production_environment)

The `is_production_environment` function checks whether the production environment is using.

#### `is_local_environment()`

[](#is_local_environment)

The `is_local_environment` function checks whether the local environment is using.

#### `is_testing_environment()`

[](#is_testing_environment)

The `is_testing_environment` function checks whether the testing environment is using.

### Math

[](#math)

#### `calculate_percentage($count, $total, int $decimals)`

[](#calculate_percentagecount-total-int-decimals)

The `calculate_percentage` function calculates percentages.

#### `calculate_discount($discount, $total, int $decimals)`

[](#calculate_discountdiscount-total-int-decimals)

The `calculate_discount` function calculates discount.

#### `calculate_with_discount($discount, $total, int $decimals)`

[](#calculate_with_discountdiscount-total-int-decimals)

The `calculate_with_discount` function calculates price with discount.

#### `has_float_remainder(float $number)`

[](#has_float_remainderfloat-number)

The `has_float_remainder` function checks whether the remainder of the float is not zero.

#### `convert_bytes($value, string $returnType)`

[](#convert_bytesvalue-string-returntype)

The `convert_bytes` function converts bytes between any sizes.

#### `get_size_types()`

[](#get_size_types)

The `get_size_types` function returns the list all available size types.

#### `is_number_even($number)`

[](#is_number_evennumber)

The `is_number_even` function checks whether the number is even.

#### `is_number_odd($number)`

[](#is_number_oddnumber)

The `is_number_odd` function checks whether the number is odd.

#### `is_number_in_range($number, $from, $to)`

[](#is_number_in_rangenumber-from-to)

The `is_number_in_range` function checks whether the number is in a given range.

Model
-----

[](#model)

#### `get_model_from_query($query)`

[](#get_model_from_queryquery)

The `get_model_from_query` function returns a model from a query.

#### `destroy_models_from_query($query)`

[](#destroy_models_from_queryquery)

The `destroy_models_from_query` function destroy all models from a query. Useful when you want to delete many models with calling model's hooks.

#### `is_morphed_belongs_parent(Model $morphed, Model $parent, string $name, string $type, string $id)`

[](#is_morphed_belongs_parentmodel-morphed-model-parent-string-name-string-type-string-id)

The `is_morphed_belongs_parent` function determines whether morphed model is belongs to parent.

### Request

[](#request)

#### `is_request_method_update($request)`

[](#is_request_method_updaterequest)

The `is_request_method_update` function checks whether the current request method is for updating.

### Server

[](#server)

#### `long_processes()`

[](#long_processes)

The `long_processes` function sets the maximum value of the optimal configuration for the server to perform long operations.

#### `get_upload_max_filesize(string $returnType)`

[](#get_upload_max_filesizestring-returntype)

The `get_upload_max_filesize` function returns the value of the `upload_max_filesize` from `php.ini` in any of the formats.

#### `get_post_max_size(string $returnType)`

[](#get_post_max_sizestring-returntype)

The `get_post_max_size` function returns the value of the `post_max_size` from `php.ini` in any of the formats.

#### `is_max_post_size_exceeded()`

[](#is_max_post_size_exceeded)

The `is_max_post_size_exceeded` function checks whether is the permissible size of the value `post_max_size` exceeded.

#### `get_max_response_code()`

[](#get_max_response_code)

The `get_max_response_code` function returns maximum available value for response code.

### String

[](#string)

#### `str_lower(string $string)`

[](#str_lowerstring-string)

The `str_lower` is function wrapper over `Str::lower`.

#### `str_upper(string $string)`

[](#str_upperstring-string)

The `str_upper` is function wrapper over `Str::upper`.

#### `str_ucwords(string $string)`

[](#str_ucwordsstring-string)

The `str_ucwords` function converts a value to studly caps case with spaces.

#### `strpos_all(string $haystack, string $needle, bool $caseInsensitive = false)`

[](#strpos_allstring-haystack-string-needle-bool-caseinsensitive--false)

The `strpos_all` function returns all occurrences of `$needle` in a `$haystack`

### Type

[](#type)

#### `random_bool()`

[](#random_bool)

The `random_bool` function returns a random boolean value.

#### `casting_bool($value, bool $default)`

[](#casting_boolvalue-bool-default)

The `casting_bool` function returns casted boolean value.

#### `is_json($json, $returnDecoded)`

[](#is_jsonjson-returndecoded)

The `is_json` function check whether passed string is a json.

#### `is_uuid($string)`

[](#is_uuidstring)

The `is_uuid` function check whether passed value is a valid uuid value.

Url
---

[](#url)

#### `get_base_url(string $url)`

[](#get_base_urlstring-url)

The `get_base_url` function returns base url.

#### `get_host_url(string $url, bool $stripWww = true)`

[](#get_host_urlstring-url-bool-stripwww--true)

The `get_host_url` function returns host url.

#### `routes_path(string $path)`

[](#routes_pathstring-path)

The `routes_path` function returns path to `routes` folder.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance80

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~280 days

Total

42

Last Release

105d ago

Major Versions

v1.0.9 → v2.02018-01-14

v1.0.10 → v2.0.62018-05-22

v2.7 → v3.02022-05-26

PHP version history (2 changes)v1.0PHP &gt;=7.0

v3.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d955f96ce398c754d6bde2173fee2eccb9bc60157e6888c0346fe1d2ab057e16?d=identicon)[MCMatters](/maintainers/MCMatters)

---

Top Contributors

[![MCMatters](https://avatars.githubusercontent.com/u/3148853?v=4)](https://github.com/MCMatters "MCMatters (94 commits)")

---

Tags

helperslaravellaravel-5-package

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mcmatters-laravel-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/mcmatters-laravel-helpers/health.svg)](https://phpackages.com/packages/mcmatters-laravel-helpers)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
