Created
December 9, 2016 06:13
-
-
Save sworup/cb6a19dee706d1181bd340cc8366ec8b to your computer and use it in GitHub Desktop.
Load config files from a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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