PHPackages                             hxgf/x-utilities - 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. hxgf/x-utilities

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

hxgf/x-utilities
================

A collection of utility functions to help do things faster with PHP.

1.2.3(1y ago)051[8 issues](https://github.com/jyoungblood/x-utilities/issues)2MITPHP

Since May 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jyoungblood/x-utilities)[ Packagist](https://packagist.org/packages/hxgf/x-utilities)[ Docs](https://github.com/jyoungblood/x-utilities)[ RSS](/packages/hxgf-x-utilities/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)DependenciesVersions (8)Used By (2)

[![](https://raw.githubusercontent.com/jyoungblood/vphp.dev/refs/heads/master/public/vphp-logo-100.png)](https://vphp.dev)

X-Utilities
===========

[](#x-utilities)

### A collection of standalone utility functions to help do things faster with PHP.

[](#a-collection-of-standalone-utility-functions-to-help-do-things-faster-with-php)

Installation
============

[](#installation)

Easy install with composer:

```
composer require jyoungblood/x-utilities

```

```
use VPHP\x;
require __DIR__ . '/vendor/autoload.php';
```

Usage
=====

[](#usage)

x::email\_send($parameters)
---------------------------

[](#xemail_sendparameters)

Sends a plain text or html email using the native PHP [mail()](https://www.php.net/manual/en/function.mail.php) function.

```
x::email_send([
  'to' => 'recipient@domain.com',
  'from' => 'sender@example.com',
  'cc' => 'cc-address@example.com',  // optional
  'bcc' => 'bcc-address@example.com',  // optional
  'reply-to' => 'reply-address@example.com',  // optional
  'subject' => 'Send me an email',
  'html' => true,  // optional, message will be sent as plain text unless this is true
  'message' => 'Right now...RIGHT NOW'
]);
```

Messages can be sent using the Mailgun API if Mailgun credentials are available as environment variables like this:

```
$_ENV['MAILGUN_API_KEY'] = 'key-f453654gg65sd6234r6rw5df6544e';
$_ENV['MAILGUN_DOMAIN'] = 'notifications.example.com';
```

or in your project's `.env` file:

```
MAILGUN_API_KEY="key-f453654gg65sd6234r6rw5df6544e"
MAILGUN_DOMAIN="notifications.example.com"

```

x::client\_ip()
---------------

[](#xclient_ip)

Returns the address of the computer making the current request.

```
echo x::client_ip();
```

x::url\_slug($string)
---------------------

[](#xurl_slugstring)

Returns a lowercase URL-safe version of a given string, substituting `-` for spaces and punctuation.

```
echo x::url_slug('John User Name');
// john-user-name
```

x::url\_strip($url)
-------------------

[](#xurl_stripurl)

Removes the protocol and trailing slashes from a given url, returning only the domain name.

```
echo x::url_strip('https://example.com/');
// example.com
```

x::url\_validate($url)
----------------------

[](#xurl_validateurl)

Returns a valid URL, adding `http://` if needed.

```
echo x::url_validate('example.com');
// http://example.com
```

x::br2nl($string)
-----------------

[](#xbr2nlstring)

The opposite of `nl2br()`, replaces `` (and ``) html tags with newline (`\n`) character.

```
echo x::br2nl('This is a  multi-line  string!');
// This is a \n multi-line \n string!
```

x::array\_encode($array)
------------------------

[](#xarray_encodearray)

Turns an array of strings into a single string, separated by a vertical bar (`|`) character.

```
echo x::array_encode(['Peter', 'Paul', 'Ringo', 'George']);
// Peter|Paul|Ringo|George
```

x::array\_decode($string)
-------------------------

[](#xarray_decodestring)

Turns a string separated by a vertical bar (`|`) character into an array of strings.

```
$people = x::array_decode('Peter|Paul|Ringo|George');
print_r($people);
// ['Peter', 'Paul', 'Ringo', 'George']
```

x::console\_log($input, $parameters)
------------------------------------

[](#xconsole_loginput-parameters)

Prints an array, object, or string in a stylized DOM container. Input type is automatically detected, and optional parameters can be used to customize the style of the container.

Typical usage:

```
x::console_log(['example' => 'array']);
```

With optional parameters:

```
x::console_log(['example' => 'array'], [
  'format' => false, // removes all container formatting
  'style' => [ // defines custom styles for container formatting
    'font-size' => '16px',
    'background' => 'blue',
    'color' => 'yellow',
    'padding' => '2.5rem',
    'line-height' => '200%',
    'custom' => 'font-style: italic'
  ]
]);
```

x::dd($input, $parameters)
--------------------------

[](#xddinput-parameters)

Same as `console_log()`, but with with a `die()` function called afterward. The same parameters are available for styling the container. Yes, it's kinda like Laravel's [dd()](https://laravel.com/docs/9.x/collections#method-dd) method.

```
x::dd(['example' => 'array']);
```

x::file\_write($input, $target\_filename, $parameters)
------------------------------------------------------

[](#xfile_writeinput-target_filename-parameters)

Appends a string, array, or object to a given file. Input type is automatically detected and converted to plain text. Optional parameters can be used to customize [fopen() mode](https://www.php.net/manual/en/function.fopen.php) and newline behavior.

```
x::file_write('A string to append to a file', 'data.txt');
```

Using custom parameters:

```
x::file_write(
  ['array_example' => 'An array to append to a file'],
  'data.txt',
  [
    'mode' => 'w+', // define PHP fopen mode, default is 'a'
    'line_beginning' => "\n- ", // prepend to beginning of input
    'line_ending' => "", // append end of input, default is PHP_EOL
  ]
);
```

x::error\_log($input, $parameters)
----------------------------------

[](#xerror_loginput-parameters)

Abstraction for the native PHP [error\_log()](https://www.php.net/manual/en/function.error-log.php) function, appends a timestamp with a given string, array, or object to an `error_log` file. Input type is automatically detected and converted to plain text.

```
x::error_log('Something bad happened.');
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

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

Recently: every ~211 days

Total

7

Last Release

600d ago

Major Versions

0.1.0 → 1.0.02022-05-20

### Community

Maintainers

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

---

Top Contributors

[![jyoungblood](https://avatars.githubusercontent.com/u/56104?v=4)](https://github.com/jyoungblood "jyoungblood (24 commits)")

---

Tags

utilities

### Embed Badge

![Health badge](/badges/hxgf-x-utilities/health.svg)

```
[![Health](https://phpackages.com/badges/hxgf-x-utilities/health.svg)](https://phpackages.com/packages/hxgf-x-utilities)
```

###  Alternatives

[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[lodash-php/lodash-php

A port of Lodash to PHP

527719.0k5](/packages/lodash-php-lodash-php)[kartik-v/yii2-helpers

A collection of useful helper functions for Yii Framework 2.0

883.0M29](/packages/kartik-v-yii2-helpers)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)[mathiasverraes/classfunctions

Functions to manipulate class names

34472.6k10](/packages/mathiasverraes-classfunctions)[kunstmaan/utilities-bundle

The KunstmaanUtilitiesBundle makes your life easier by providing a couple of small but usefull helper services you can use and re-use in your applications. We already implemented an easy to use cipher service and a shell helper service for you but feel free to send in a pull request with your additions. The shell helper allows you to run apps in the background, see if a process is running and has a method to kill a running process. The cipher service allow you to encode and decode strings using the Rijndael 256 cipher

13150.5k6](/packages/kunstmaan-utilities-bundle)

PHPackages © 2026

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