@nakov , the way to load helper file is correct, But I will suggest to use a class instead of helper function. Because if you define a file under auto-load, then file loads in every request, So it will be good create folder in app dir like:
@hitesh399 I would agree, but the functions are just being loaded as there are hundreds of other helper files. I've been using this method, and haven't felt any performance issues. :)
Using your approach is okay, but anytime the function needs to be used, an object needs to be passed to the view, which does not makes the process easy :)
@nakov , As you can see in laravel latest version, Laravel has been removed some helper functions. So I think, To use class instead of function is Good way.
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Session;
use App\Helpers\Url;
use Illuminate\Support\Facades\Auth;
class Clnsantize
{
public static function fixValue($rvalue)
{
$rvalue = empty($rvalue) && !is_numeric($rvalue) ? NULL : trim(strip_tags($rvalue));
return $rvalue;
}
///// more methods
Or if you insist on instance, you can use __callStatic(), or in laravel make a facade, which just uses __callStatic() anyway.