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

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

marshmallow/helpers
===================

A package containing all the helper function we can use throughout all our projects

v2.21.0(2mo ago)224.2k↑100%113MITPHPPHP ^7.0|^8.0CI failing

Since Mar 22Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (64)Used By (13)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Marshmallow Deployer
====================

[](#marshmallow-deployer)

We have build a package with some helpers that are usefull in almost every project. We use this package in all our projects. For ourself and for our customers. If you miss anything, create an issue and will will add it as soon as possible.

[![Version](https://camo.githubusercontent.com/1a070c5afa45d061dd8e99cf7ebee602bca0df5a6f2d805424e7c3b6b37a8afb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f68656c70657273)](https://github.com/marshmallow-packages/helpers)[![Issues](https://camo.githubusercontent.com/5c15037d5e8e22b7a0a6407a5df234269bfebd0c0dccec0d9588e1bfaac29b65/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d617273686d616c6c6f772d7061636b616765732f68656c70657273)](https://github.com/marshmallow-packages/helpers)[![Code Coverage](https://camo.githubusercontent.com/a47a770765f8c7b5776c024ff602bfc3f3686ba8be5317b3d0c320c715df42c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d73756363657373)](https://github.com/marshmallow-packages/helpers)[![Licence](https://camo.githubusercontent.com/f8fcea2718cb73614382d26d0d97fceeac10b7d9c85e2f72b2033c077c8ddc9e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d617273686d616c6c6f772d7061636b616765732f68656c70657273)](https://github.com/marshmallow-packages/helpers)

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

[](#installation)

You can install the package via composer:

```
composer require marshmallow/helpers
```

Table of contents
=================

[](#table-of-contents)

1. [CSV Helper](#csv-helper)
2. [Helper functions](#helper-functions)
3. [String helper](#string-helper)
4. [Migrations](#migrations)
5. [URL](#url)
6. [Array](#array)
7. [Reviews](#reviews)
8. [Grouper](#grouper)

CSV Helper
----------

[](#csv-helper)

This helper will make generating .csv files extremly ease. Please check the examples below. You can use the store method to store it in a location of your choosing. You can use the download method if you just want to download the file. If you wish to store and download the generated .csv file you can use the storeAndDownload method.

### Usage example

[](#usage-example)

```
$headers = ['Column 1', 'Column 2', 'Column 3'];
$data = [
	[1, 2, 3],
	[4, 5, 6],
];

return CSV::headers($headers)
	->data($data)
	->delimiter(';')
	->setFilename('generated-csv-1234')
	->storeAndDownload();
```

### **Use a collection as data attribute**

[](#use-a-collection-as-data-attribute)

You can use a collection as your data attribute. By default it will map all the data in the collection sequence. If you wish to edit the collection data, you can add a callback method to the data method. Please note that this will give you every row as an `array` value.

```
use Marshmallow\HelperFunctions\Facades\CSV;

CSV::headers($headers)
        ->data($data, function (array $row) {
            return [
                $row['name'],
                $row['slug'],
                $row['created_at'],
            ];
        })
        ->storeAndDownload();
```

### **Store and download calls**

[](#store-and-download-calls)

The following methods are available for storing and downloading the generated csv file.

```
$csv->download();
$csv->store();
$csv->storeAndDownload();
$csv->stream();
```

Helper functions
----------------

[](#helper-functions)

### Percentage helper

[](#percentage-helper)

This is a public helper function that is available within your Laravel application. This function can be used in all your PHP and Blade files.

```
percentage(47, App\Post::get()); // 63.829787234043
```

String Helper
-------------

[](#string-helper)

The Str helper extends the helper from Laravel. So you have all the methods available in the Laravel helper available as well. Check the **[Laravel documentation](https://laravel.com/docs/helpers)** for all the available methods.

### **Str::join()**

[](#strjoin)

This method is super handy for concatenating strings separated by a comma, but use another value for the last item. Checkout the example below.

```
Str::join([
  'Marshmallow',
  'Stef van Esch',
  'Mr Mallow'
]);

// Marshmallow, Stef van Esch and Mr Mallow
```

### **Str::random()**

[](#strrandom)

We have added on the default `Str::random()` of Laravel. We've added a second parameter which is an array of characters that should be ignored. We also have build in a couple of presets like `lowercase` which will make sure the random string won't contain any lowercase characters.

```
Str::random($limit = 16, $ignore = [
    /**
     * Custom items
     */
    'A','B', 'C', 'D',

    /**
     * Presets
     */
    'lowercase', 	// Will ignore all lowercase characters.
    'uppercase',	// Will ignore all uppercase characters.
    'letters',		// Will ignore all letters.
    'numbers',		// Will ignore all numbers.
    'similar',		// Will ignore all numbers and letters that have been marked as similar.
]);
```

### **Str::cleanPhoneNumber()**

[](#strcleanphonenumber)

```
Str::cleanPhoneNumber()
```

### **Str::phonenumberWithCountryCode()**

[](#strphonenumberwithcountrycode)

Return a cleaned phonenumber with the country code. You can choose to return the phonenumber with a `+` or `00` at the start of the phonenumber.

```
Str::phonenumberWithCountryCode('0628998954')
// response: +31628998954

Str::phonenumberWithCountryCode(
    '0031628998954',
    $country_code = '31',
    $use_plus_instead_of_zeros = false
);
// response: 0031628998954
```

### **Str::numbersOnly()**

[](#strnumbersonly)

```
Str::numbersOnly()
```

### **Str::numbersAndLettersOnly()**

[](#strnumbersandlettersonly)

```
Str::numbersAndLettersOnly()
```

### **Str::readmore()**

[](#strreadmore)

```
Str::readmore(
    $string,
    $lenght_first_part,
    $return_this_part = null
);
```

### **Str::paragraphsAsArray()**

[](#strparagraphsasarray)

```
Str::paragraphsAsArray($string);
```

### **Str::getFirstParagraph()**

[](#strgetfirstparagraph)

```
Str::getFirstParagraph(
    $string,
    $number_of_paragraphs = 1,
    $return_array = false
);
```

### **Str::getAllButFirstParagraph()**

[](#strgetallbutfirstparagraph)

```
Str::getAllButFirstParagraph(
    $string,
    $number_of_paragraphs_to_skip = 1,
    $return_array = false
);
```

Migrations
----------

[](#migrations)

We have a trait available that gives you some extra options when creating migrations. Add the `MigrationHelper` trait to you migration to make use of these options.

### Implementation

[](#implementation)

```
use Marshmallow\HelperFunctions\Traits\MigrationHelper;

class CreateProductTable extends Migration
{
    use MigrationHelper;
```

### **Create a column only if it doesn't exist.**

[](#create-a-column-only-if-it-doesnt-exist)

This method was added because when a database that already has a products table and later will use our `Product` package, the migrations will through error's.

```
$this->createColumnIfDoesntExist(
    'products', 'deleted_at', function (Blueprint $table) {
        $table->softDeletes();
    }
);
```

URL
---

[](#url)

### **URL::isInternal()**

[](#urlisinternal)

```
URL::isInternal($url)
```

### **URL::isCurrent()**

[](#urliscurrent)

```
URL::isCurrent($url)
```

### **URL::buildFromArray()**

[](#urlbuildfromarray)

```
URL::buildFromArray($array)
```

### **URL::isNova()**

[](#urlisnova)

```
URL::isNova($request)
```

### **URL::isNotNova()**

[](#urlisnotnova)

```
URL::isNotNova($request)
```

Array
-----

[](#array)

### **Arrayable::storeInFile();**

[](#arrayablestoreinfile)

This method will store a pretty array in a file. With this method is possible to generate config files.

```
Arrayable::storeInFile(array $array, string $file_location);
```

Builder
-------

[](#builder)

### **Builder::published()**

[](#builderpublished)

`BuilderHelper::published` will filter on database columns if something is published.

```
public function scopePublished (Builder $builder)
{
    BuilderHelper::published(
        $builder,
        $valid_from_column,
        $valid_till_column
    );
}
```

Reviews
-------

[](#reviews)

For the review stars you can call `ReviewHelper::ratingToStars(4.5)`. By default the ReviewHelper will think you are using a max rating of 5, support half star rating and return a string of FontAwesome icons. You can overule this behaviour by;

### **Customise**

[](#customise)

Create the config file `config/review.php` and specify your needs:

```
return [
    'max_rating' => 10,
    'full_star' => '+ ',
    'half_star' => '* ',
    'empty_star' => '- ',
];
```

Or you can provide the same config array as a second parameter to the `ratingToStars` method like so;

```
ReviewHelper::ratingToStars(4.5, [
    'max_rating' => 10,
    'full_star' => '+ ',
    'half_star' => '* ',
    'empty_star' => '- ',
])
```

Grouper
-------

[](#grouper)

Grouper is a super handy helper when you need to split your queries results in to groups. We use this with blogs a lot. The first row might have 3 results, the second row will have 1 result, en the third row will have 3 items again. Please see the example below.

```
use Marshmallow\HelperFunctions\Facades\Collection;

$grouper = Collection::createGrouper(Blog::get(), $structure_array = [
    'first' => 3,
    'second' => 1,
    'third' => 2,
]);
```

As you can see in the example, the `structure_array` has a name as the key. This is done so when you are looping through your groups, you are able the test which group you are currently looping.

```
foreach ($grouper as $group) {
    if ($group->is('first')) {
        // Add your template for 3 items
    }

    if ($group->is('second')) {
        // Add your template for 1 item
    }
}
```

Looping through the group items works just like you expect when working with collections.

```
foreach ($grouper as $group) {
    foreach ($group as $blog) {
        //
    }
}
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 92.1% 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 ~35 days

Recently: every ~147 days

Total

63

Last Release

61d ago

Major Versions

v1.1.2 → v2.0.02020-06-07

PHP version history (3 changes)v1.0.0PHP &gt;=7.0.0

v2.8.2PHP ^7.0|^8.0

v2.11.2PHP ^7.0|^8.0|^8.1

### Community

Maintainers

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

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (129 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

laravel-helpersmarshmallow

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/marshmallow-helpers/health.svg)](https://phpackages.com/packages/marshmallow-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)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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