Level 18
You can also register the helpers folder in the composer classmap ;-)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I put these into a directory app\Helpers and then in the Providers directory make a new provider HelperServiceProvider. The code for this just reiterates though a directory of php files:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class HelperServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
foreach (glob(app_path().'/Helpers/*.php') as $filename){
require_once($filename);
}
}
}
finally add it to config/app under providers:
'App\Providers\HelperServiceProvider',
and all your methods are available
Please or to participate in this conversation.