Skip to content

Instantly share code, notes, and snippets.

@bpocallaghan
Last active July 12, 2017 12:32
Show Gist options
  • Save bpocallaghan/f8b6f21e352b57a8f07f08fea2965384 to your computer and use it in GitHub Desktop.
Save bpocallaghan/f8b6f21e352b57a8f07f08fea2965384 to your computer and use it in GitHub Desktop.
Laravel 5 Include Helper Files
"autoload": {
"files": [
"app/Helpers/helpers.php",
],
"psr-4": {
"App\\": "app/",
}
},
<?php
// save app/Providers/
// remember to register it in your config/app.php
// 'providers' => [
// App\Providers\HelperServiceProvider::class,
// ]
// lastly run composer dump-autoload
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class HelperServiceProvider extends ServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
foreach (glob(base_path() . '/app/Helpers/*.php') as $filename) {
require_once $filename;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment