Laravel 5.8 – add custom helper

1.44K views
no comments
21 Apr 2019 11:30 pm

Before adding your custom functions helper or library to project. Laravel have set most of useful function in helper. Read Laravel’s pre-defined functions in helper https://laravel.com/docs/helpers

So let’s start to add custom function library or helper to your project.

Create directory helpers in “LaravelProject\app\Http”

Create function helper file “func_helper.php” in
“LaravelProject\app\Http\Helpers” directory

Register (Add) func_helper.php file in project

Open file “AppServiceProvider.php”
from “LaravelProject/app/Providers” and write the following in register() method or replace the whole register method with

public function register() {
	require_once __DIR__ . '/../Http/Helpers/func_helper.php'; 
}

Add another helper just duplicate line and change file

public function register() { 
	require_once __DIR__ . '/../Http/Helpers/func_helper.php';
	require_once __DIR__ . '/../Http/Helpers/another_helper.php';
}

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>