PHPackages                             abollinger/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. abollinger/helpers

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

abollinger/helpers
==================

A set of useful functions for managing the Partez framework, but not only!

v1.3(1y ago)13865MITPHP

Since Mar 5Pushed 1y agoCompare

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

READMEChangelog (10)Dependencies (2)Versions (12)Used By (5)

Abollinger/Helpers
==================

[](#abollingerhelpers)

Provides some usefull PHP functions to help developpers in their daily work.

[![Total Downloads](https://camo.githubusercontent.com/63bb92fb37d383bed1e15db9d88c34d9aa3fa8c15a5e6bbe8101902098de6dc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61626f6c6c696e6765722f68656c70657273)](https://packagist.org/packages/abollinger/helpers)[![Latest Stable Version](https://camo.githubusercontent.com/e71d0516ce95e3480d1d40cfef1b5dbd9e9b7663bb575461579b5be3a4cf62d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61626f6c6c696e6765722f68656c70657273)](https://packagist.org/packages/abollinger/helpers)[![License](https://camo.githubusercontent.com/8bd1ac4eeb4f9b55d0a496d154dfb9d21dad7540834ad73817610dde6b6d9f0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61626f6c6c696e6765722f68656c70657273)](https://packagist.org/packages/abollinger/helpers)

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

You can easily add this library in your project using [Composer](https://getcomposer.org/):

```
composer require abollinger/helpers
```

Or add it manually in your `composer.json` file.

Usage
-----

[](#usage)

Here are all the function you can, showd in the Classes tree they belong to:

 Functions in the Classes tree- Abollinger/
    - Helpers::
        - [cleanArray($array)](#cleanarray)
        - [printArray($array, $classes)](#printarray)
        - [mapJoinArray($array, $callback, $separator)](#mapJoinArray)
        - [defaultParams($default, $array)](#defaultparams)
        - [getYaml($filePath)](#getyaml)
        - [getScan($dir, $rootDir, $allData)](#getscan)
        - [isAssociativeArray($array)](#isassociativearray)
        - [largestElementInArray($array)](#largestelementinarray)
        - [defineConstants($array)](#defineconstants)
        - [getAppSubdirectory($appRoot, $documentRoot)](#getAppSubdirectory)
        - [getAppCompleteHost()](#getAppCompleteHost)
        - [convertRouteToRegex()](#convertRouteToRegex)
    - Parsedown::
        - [extends the erusev/parsedown library](#erusev/parsedown)

 ### cleanArray

[](#cleanarray)

Function that clean an array of parameters using the htmlspecialchars functions, to avoid the risk of XSS attacks.

- `@param array $arr`: The array that is to be cleaned.
- `@return array`: The cleaned array. Returns false if @param is not an array.

Example :

```
$myArray = Helpers::cleanArray([
    "attack" => "alert('Hey, I'm trying to hack you!')"
]);

echo var_dump($myArray);

// output:

array(1) {
    ["attack"]=>
    string(66) "&lt;script&gt;alert('Hey, I'm trying to hack you!')&lt;/script&gt;"
}

```

### printArray

[](#printarray)

Render PHP array into a HTML ul list

- `@param array $arr`: The array to render as a list.
- `@param array $classes`: A array of classes to apply to the ul/li. Expecting \["ul" =&gt; "classForTheUlTag", "li" =&gt; "classForTheLiTag"\].
- `@return string`: Default return is an empty string, else it's a HTML ul list of the array.

Example :

```
$myArray = Helpers::printArray([
    "firstName" => "Antoine",
    "lastName" => "Bollinger"
]);

echo $myArray;

// output:

    firstName => Antoine
    lastName => Bollinger

```

### mapJoinArray

[](#mapjoinarray)

Function that applies a callback to each key-value pair in the array and joins the results into a string.

- `@param array $arr`: The input array whose elements will be transformed.
- `@param callable $callback`: A function with signature function($key, $value): string
- `@param string $separator`: A string to insert between each transformed element.
- `@return string`: A single string composed of transformed elements separated by the given separator.

### defaultParams

[](#defaultparams)

Function that create an array of default value that will be replace by the client value when exist \*

- `@param array $default`: an array of default values that are necessary but not mandatory on client side.
- `@param array $params`: an array of parameters mandatories that will be filled with the default values.
- `@return array`: the array $params filled with default values.

Example:

```
$params = [
    "firstName" => "Victor"
];

$test = Abollinger\Helpers::defaultParams([
    "firstName" => "Antoine",
    "lastName" => "Bollinger"
], $params);

echo var_dump($test);

// output:
array(2) {
    ["firstName"] => string(6) "Victor"
    ["lastName"] => string(9) "Bollinger"
}

```

### getYaml

[](#getyaml)

Yaml files reader returning the content as a array. Base on Symfony/Yaml package.

- `@param string $filePath`: The path to the YAML file.
- `@return array`: Return a PHP array of the YAML file content.

### getScan

[](#getscan)

Scan a directory and return an array of all paths. Escape the .class.php files.

- `@param string $dir`: Directory to scan.
- `@param string $rootDir`: Root of the directory. Initially $dir = $rootDir, but in the loop $dir will change.
- `@return array`: Array of all detailles path/files. Not nested.

### isAssociativeArray

[](#isassociativearray)

Function that evaluate if an array is Associative (ex.: \["key1" =&gt; "value1", "key2" =&gt; "value2"\]) or not (\["value1", "value2"\]).

- `@param array $arr`: An array to be evaluated.
- `@return bool`: True if the array is associative, false otherwise.

### largestElementInArray

[](#largestelementinarray)

Function that determine the max lenght among elements of an array

- `@param array $arr`: An array to be evaluated.
- `@return int`: The max lenght.

### defineConstants

[](#defineconstants)

Defines constants from an associative array if they are not already defined.

- `@param array $arr`: An associative array containing constant names as keys and their respective values.
- `@return bool`: Returns true if constants are defined or if the input is not an array. Returns false otherwise.

### getAppSubdirectory

[](#getappsubdirectory)

Function that returns the subdirectory path of an application relative to the document root.

- `@param string $appRoot`: The path to the application's root directory.
- `@param string $documentRoot`: The path to the document root directory.
- `@return string`: The subdirectory path or an empty string if the document root is longer than or equal to the application root.

### getAppCompleteHost

[](#getappcompletehost)

This function returns the complete host URL of the current application.

- `@return string`: The complete host URL of the current application.

### convertRouteToRegex

[](#convertroutetoregex)

This function takes a route string containing placeholders in curly braces (e.g., "/user/{id}/profile") and converts it into a regex pattern that can be used for matching and extracting named parameters. For example:

- Input: "/user/{id}/profile"
- Output: "#^/user/(?P\[^/\]+)/profile$#"

### Parsedown

[](#parsedown)

Extends the [erusev/parsedown](https://github.com/erusev/parsedown) library by adding # in the title, so the anchor links can work.

Classes tree
------------

[](#classes-tree)

```
Abollinger/
├── Helpers::
│   ├── cleanArray($array)
│   ├── printArray($array, $classes)
│   ├── defaultParams($default, $array)
│   ├── getYaml($filePath)
│   ├── getScan($dir, $rootDir, $allData)
│   ├── isAssociativeArray($array)
│   ├── largestElementInArray($array)
│   ├── defineConstants($array)
│   ├── getAppSubdirectory($appRoot, $documentRoot)
│   └── getAppCompleteHost()
└── Parsedown::
    └── extends the erusev/parsedown library
```

Licence
-------

[](#licence)

This library is licensed under the MIT License. For full license details, see the `LICENCE` file distributed with this source code.

Author
------

[](#author)

Antoine Bollinger Email:

For contributions, issues, or feedback, feel free to contact the author or open a GitHub issue.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance49

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~43 days

Recently: every ~99 days

Total

11

Last Release

369d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ef76077f29bfc3b32b0b1d21d2f4122af8109f23aa48586ea68d768e01f354f?d=identicon)[antoinebollinger](/maintainers/antoinebollinger)

---

Top Contributors

[![antoinebollinger](https://avatars.githubusercontent.com/u/56133015?v=4)](https://github.com/antoinebollinger "antoinebollinger (22 commits)")

### Embed Badge

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

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

###  Alternatives

[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

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