Lumen, Laravel 겸용 패키지 만들기

Submitted by river - 등록 8 years ago - 수정 8 years ago

패키지를 개발할 때, LaravelLumen을 동시에 지원하고자 한다면, config 관련해서는 다음의 방법을 사용할 수 있다.

class SampleServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__.'/../../config/config.php' => $this->getConfigPath(),
        ], 'config');
    }

    .
    .
    .

    private function isLumen()
    {
        return str_contains($this->app->version(), 'Lumen');
    }

    private function getConfigPath()
    {
        if ($this->isLumen()) {
            return base_path('config/mailgun.php');
        } else {
            return config_path('mailgun.php');
        }
    }
}
comments powered by Disqus