PHPackages                             mbs-dev/php-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. mbs-dev/php-helpers

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

mbs-dev/php-helpers
===================

A collection of utility functions designed to streamline common tasks within PHP projects.

v1.0.0(1y ago)115MITPHPPHP ^8.1

Since Jul 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MOHAMMED-BE/php-helpers)[ Packagist](https://packagist.org/packages/mbs-dev/php-helpers)[ RSS](/packages/mbs-dev-php-helpers/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

PHP Helper Functions
====================

[](#php-helper-functions)

This package provides a collection of utility functions designed to streamline common tasks in PHP projects. It includes a variety of helpers for file handling, string manipulation, distance calculation, and more.

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

[](#installation)

You can install this package via Composer:

```
composer require mbs-dev/php-helpers
```

Usage
-----

[](#usage)

Import Helpers:

```
use App\Helpers\Helpers;
```

### Available Functions:

[](#available-functions)

- 1 : getFileMimeType
- 2 : extractIdFromApiUrl
- 3 : slugify
- 4 : createUploadedFile
- 5 : generateRandomString
- 6 : genererCodeAlphanumerique
- 7 : getDistanceBetweenPoints
- 8 : extractFormData
- 9 : parseMultipartFormData

---

### Function Details:

[](#function-details)

- 1 : `getFileMimeType`

Gets the mime type of a file.

Parameters:

UploadedFile $picture: The uploaded file object. Returns: string - The mime type of the file.

Example:

```
use Symfony\Component\HttpFoundation\File\UploadedFile;

$helpers = new Helpers();
$mimeType = $helpers->getFileMimeType($uploadedFile);
echo $mimeType; // Outputs the mime type
```

- 2 : `extractIdFromApiUrl`

Extracts an ID from a given API URL.

Parameters:

string $url: The URL from which to extract the ID. Returns: ?int - The extracted ID or null if not found.

Example:

```
$id = Helpers::extractIdFromApiUrl('https://api.example.com/resource/123');
echo $id; // Outputs: 123
```

- 3 : `slugify`

Converts a string into a URL-friendly slug.

Parameters:

string $text: The text to slugify. Returns: string - The slugified text.

Example:

```
$slug = Helpers::slugify('Hello World!');
echo $slug; // Outputs: hello-world
```

- 4 : `createUploadedFile`

Creates an UploadedFile instance from a given path.

Parameters:

string $path: The path to the original file. string $copiedImagePath: The path where the copied image will be stored.

Example: Returns: UploadedFile - The created UploadedFile instance.

```
$uploadedFile = Helpers::createUploadedFile('/path/to/original.jpg', '/path/to/copied.jpg');
```

- 5 : `generateRandomString`Generates a random string based on the current date and time.

Example: Returns: string - The generated random string.

$randomString = Helpers::generateRandomString(); echo $randomString; // Outputs a random string

- 6 : `genererCodeAlphanumerique`Generates an alphanumeric code of specified length.

Parameters:

int $longueur: The length of the code. Returns: string - The generated code.

Example:

```
$code = Helpers::genererCodeAlphanumerique(10);
echo $code; // Outputs a 10-character alphanumeric code
```

- 7 : `getDistanceBetweenPoints`

Calculates the distance between two geographic points.

Parameters:

float $lat1: Latitude of the first point. float $lon1: Longitude of the first point. float $lat2: Latitude of the second point. float $lon2: Longitude of the second point. string $unit: The unit of distance ('mile', 'foot', 'yard', 'km', 'm'). Returns: float - The distance between the points in the specified unit.

Example:

```
$distance = Helpers::getDistanceBetweenPoints(40.748817, -73.985428, 34.052235, -118.243683, 'km');
echo $distance; // Outputs the distance in kilometers
```

- 8 : `extractFormData`

Extracts form data from a request.

Parameters:

\\Symfony\\Component\\HttpFoundation\\Request $request: The request object. Returns: array - The extracted form data.

Example:

```
$formData = $helpers->extractFormData($request);
print_r($formData); // Outputs the form data
```

- 9 : `parseMultipartFormData`

Parses multipart form data from a request.

Parameters:

\\Symfony\\Component\\HttpFoundation\\Request $request: The request object. Returns: array - The parsed form data.

Example:

```
$formData = Helpers::parseMultipartFormData($request);
print_r($formData); // Outputs the parsed form data
```

License
=======

[](#license)

This package is open-sourced software licensed under the MIT license.

This README provides a comprehensive guide to using your helper functions in a PHP project. Adjust the "Installation" section as needed based on your package's specific details. ​:citation\[oaicite:0\]{index=0}​

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

708d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12978897?v=4)[MBS Developers](/maintainers/mbs-dev)[@mbs-dev](https://github.com/mbs-dev)

---

Top Contributors

[![MOHAMMED-BE](https://avatars.githubusercontent.com/u/79972791?v=4)](https://github.com/MOHAMMED-BE "MOHAMMED-BE (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mbs-dev-php-helpers/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[illuminate/session

The Illuminate Session package.

9939.3M850](/packages/illuminate-session)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[symfony/ux-autocomplete

JavaScript Autocomplete functionality for Symfony

645.9M39](/packages/symfony-ux-autocomplete)[illuminate/cookie

The Illuminate Cookie package.

244.6M136](/packages/illuminate-cookie)[codefog/contao-news_categories

News Categories bundle for Contao Open Source CMS

3189.0k6](/packages/codefog-contao-news-categories)

PHPackages © 2026

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