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

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

brio/helpers
============

Custom helpers

2.5.0(6y ago)51062[3 issues](https://github.com/MarcBrillault/helpers/issues)MITPHPPHP &gt;=5.6

Since Mar 27Pushed 3y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (11)Used By (0)

My personal helpers
===================

[](#my-personal-helpers)

These are some of the functions I use intensively for my projects.

As I don't want my functions to interfere with any of yours, they all use the `Embryo` namespace.

Array helpers
=============

[](#array-helpers)

arrayDepth
----------

[](#arraydepth)

This function returns the depth of a given array.

- 0 if the array is empty
- 1 for unidimensional arrays
- 2 to x for every other array types

WARNING: a recursive array could currently cause an infinite loop (See issue #29).

Command Line Interface (CLI) helpers
====================================

[](#command-line-interface-cli-helpers)

These helpers are made specifically for command-line interfaces (CLI)

cliArguments
------------

[](#cliarguments)

Just add `$args = Embryo\cliArguments();` at the beginning of your CLI script, and use your CLI script as you do with a bash script.

```
php myScript.php -action makeSomething -verbose

```

The array `$args` will now contain :

- action: 'makeSomething'
- verbose: true

You can also give an array of allowed arguments in the first parameter of `cliArguments()`. Any parameter other than the ones listed will generate and error and die.

cliClear
--------

[](#cliclear)

Calling this function clears the command line interface. Tested with Windows and Unix environments.

cliIsInterface
--------------

[](#cliisinterface)

Tells whether the current script is called in a command-line interface.

cliProgressBar
--------------

[](#cliprogressbar)

Displays a nice progressBar.

Since the display is updated less frequently than the spinner, it is slightly quicker than `cliSpinner`.

```
foreach($myvar as $var) {
    Embryo\cliProgressBar($currentIndex, $total);
}
```

cliPrompt
---------

[](#cliprompt)

Prompts a question to the user, and returns a boolean: `true` if the answer is the first letter or the first answer, `false` in every other case.

If no answers are set, default answers are `[y]es / [n]o`

```
Embryo\cliPrompt('Do you want to continue ?');
```

Will display `Do you want to continue ? [y]es / [n]o`, and will return true if the answer is either `y` or `yes`.

```
Embryo\cliPrompt('Do you want to continue ?', ['continue', 'abort']);
```

Will display `Do you want to continue ? [c]ontinue / [a]bort`, and will return true if the answer is either `c` or `continue`.

cliQuestion
-----------

[](#cliquestion)

Displays a question to the user, and returns its answer as a string.

```
$answer = Embryo\cliQuestion('What is the airspeed velocity of an unladen swallow ?');
```

cliSpinner
----------

[](#clispinner)

Adds a nice spinner to your loops.

```
foreach($myvar as $var) {
    Embryo\cliSpinner('Manipulating data');
    // Do something
}
Embryo\cliSpinner('Done !', true);
```

cliTable
--------

[](#clitable)

Displays an array as a readable table.

By default, the first value's keys will be used as header names.

```
$table = [
    [
        'id'    => 1,
        'name'  => 'John Doe',
        'email' => 'john@doe.com',
    ],
    [
        'id'    => 2,
        'name'  => 'Jane Doe',
        'email' => 'jane@doe.com',
    ],
];

echo Embryo\cliTable($table);
```

will be displayed like this :

```
╔════╤══════════╤══════════════╗
║ id │ name     │ email        ║
╟────┼──────────┼──────────────╢
║  1 │ John Doe │ john@doe.com ║
║  2 │ Jane Doe │ jane@doe.com ║
╚════╧══════════╧══════════════╝

```

Debug helpers
=============

[](#debug-helpers)

d
-

[](#d)

Dumps a variable. The second parameters allows to dump only if the corresponding $\_REQUEST ($\_GET or $\_POST) parameter exists, and is equivalent to true.

```
\Embryo\d($myVar);
```

dd
--

[](#dd)

Like `\Embryo\d()`, this function dumps a variable. It also dies just after.

If nothing has been sent to the browser before the call, and the data is an array or an object, a json header will be sent and the data will be displayed as a json string.

pp
--

[](#pp)

Pretty prints a given value by wrapping a var\_dump into `` tags

SEO helpers
===========

[](#seo-helpers)

seoUrl
------

[](#seourl)

Creates an URL from any UTF-8 compatible given string.

It removes the accents, and replaces all non-alphanumeric character by hyphens.

```
$url = \Embryo\seoUrl("I'm giving my résumé to the café, Señor !");
// $url equals 'i-m-giving-my-resume-to-the-cafe-senor'
```

unparseUrl
----------

[](#unparseurl)

This method is intended to be a reverse of PHP's builtin [parse\_url](http://php.net/manual/en/function.parse-url.php). The parsed url's `query` key can be a string or an array.

string helpers
==============

[](#string-helpers)

strBase64ImageEncode
--------------------

[](#strbase64imageencode)

Returns the correct base64 value for a given image path.

strComplete
-----------

[](#strcomplete)

Completes a string to a given length. If the length is shorter than the string, it will return the full, non-altered string.

```
$str = \Embryo\strComplete('test', 10, ' ');
// $str is 'test      '
```

strCut
------

[](#strcut)

Cuts a text at a given number of characters.

If `$isTotalLength` is set to `true`, the final maximum length will be `$length`. If it set to false, the final maximum length will be `$length + strlen($end)`.

If $length is &gt;= 40, the function will not cut into a word, but just after the previous word.

strIsFourByteUtf8
-----------------

[](#strisfourbyteutf8)

Tells whether a string contains four-byte UTF-8 characters

strIsJson
---------

[](#strisjson)

Tells whether a given string is valid JSON

strIsUtf8
---------

[](#strisutf8)

Tells whether a given string is encoded in UTF-8.

strIsXml
--------

[](#strisxml)

Returns whether the given string contains valid XML code (including HTML)

strRemoveAccents
----------------

[](#strremoveaccents)

Removes all accented characters from a given string.

strRemoveFourByteUtf8Characters
-------------------------------

[](#strremovefourbyteutf8characters)

Removes all four-bytes UTF-8 characters from a given UTF-8 string.

It can be used to prevent `Illegal mix of collation` errors in your database queries, for example, if your database is not set to UTF8MB4.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

10

Last Release

2449d ago

Major Versions

1.1.0 → 2.0.02018-01-06

PHP version history (2 changes)1.1.0PHP &gt;=5.6

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/66ebada9ef733ae4cde52a5a5ea84736532e398edb699b94dfa8bdfaa5392511?d=identicon)[captain\_torche](/maintainers/captain_torche)

---

Top Contributors

[![MarcBrillault](https://avatars.githubusercontent.com/u/2051814?v=4)](https://github.com/MarcBrillault "MarcBrillault (72 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[botman/botman

Create messaging bots in PHP with ease.

6.2k1.5M96](/packages/botman-botman)[slowprog/composer-copy-file

Composer script copying your files after install

481.0M29](/packages/slowprog-composer-copy-file)[denngarr/seat-fitting

Module to check fittings per character

1433.2k2](/packages/denngarr-seat-fitting)[thedmsgroup/mautic-enhancer-bundle

Various contact enhancer integrations for Mautic.

342.8k](/packages/thedmsgroup-mautic-enhancer-bundle)[francescomalatesta/laravel-amplitude

A Laravel package to work with Amplitude.

125.3k](/packages/francescomalatesta-laravel-amplitude)[xi/breadcrumbs-bundle

Xi breadcrumbs bundle for Symfony2 that utilises routes as a tree to build the breadcrumbs in order to not pollute the controller actions with repetitive breadcrumbs code.

113.2k](/packages/xi-breadcrumbs-bundle)

PHPackages © 2026

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