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

ActiveLibrary

mercuryseries/laravel-helpers
=============================

Dynamic Method Helpers

1.0.5(5y ago)331.7k5MITPHPPHP &gt;=7.0.0

Since Nov 7Pushed 5y ago6 watchersCompare

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

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

Dynamic Method Helpers
======================

[](#dynamic-method-helpers)

Before using Laravel I was a big fan of Ruby on Rails and the feature that I loved the most about Ruby on Rails was the ability to create a helper method (in a module) and being able to call it like a global method.

```
Module BooksHelper
  def format_price(book)
    if book.free?
      content_tag(:strong, 'Free!')
    else
      number_to_currency(book.price)
    end
   end
end
```

```

```

Pretty cool isn't it?

Now as you might guess I want to have the same thing in Laravel.

Oh I should have said I have the same thing now with Laravel :)

**Disclaimer**: Of course you can create a folder with many files helpers or just one global file helper and autoload it with Composer but I rather prefer to create a class and it's much more clear when testing. So everyone may not like it!

Here are the steps if you also want it:

Install the package through Composer
------------------------------------

[](#install-the-package-through-composer)

```
composer require mercuryseries/laravel-helpers

```

Register the package service provider in `config/app.php` by adding:
--------------------------------------------------------------------

[](#register-the-package-service-provider-in-configappphp-by-adding)

```
MercurySeries\Helpers\HelpersServiceProvider::class,
```

Create a `Helpers` directory in your `app` folder.
--------------------------------------------------

[](#create-a-helpers-directory-in-your-app-folder)

Now you can create a `Helpers` directory in your `app` folder.

Add some classes with your helper methods
-----------------------------------------

[](#add-some-classes-with-your-helper-methods)

PS: All helper methods need to be static.

```
