Skip to content

Instantly share code, notes, and snippets.

@sworup
Created December 9, 2016 06:13
Show Gist options
  • Save sworup/cb6a19dee706d1181bd340cc8366ec8b to your computer and use it in GitHub Desktop.
Save sworup/cb6a19dee706d1181bd340cc8366ec8b to your computer and use it in GitHub Desktop.
Load config files from a directory
<?php
namespace Sworup\Providers;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\Finder\Finder;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
}
public function register()
{
$directory = __DIR__.’/../config2’;
foreach (Finder::create()->in($this->directory)->name(‘*.php’) as $file)
{
$this->mergeConfigFrom( $file->getRealPath() , basename($file->getRealPath(), ‘.php’) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment