Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jim1506's avatar

If you have a lot of php method files that you have built up over the years...

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

0 likes
1 reply
Braunson's avatar

You can also register the helpers folder in the composer classmap ;-)

Please or to participate in this conversation.