Last active
February 11, 2017 21:29
-
-
Save shawnsandy/cc74e7f18887d03690f935a1b5ed3e25 to your computer and use it in GitHub Desktop.
Sample Package Service Provider
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: Shawn | |
* Date: 2/11/2017 | |
* Time: 12:37 PM | |
*/ | |
namespace ShawnSandy\GitContent\Stories; | |
use Illuminate\Support\ServiceProvider; | |
class StoriesProvider extends ServiceProvider | |
{ | |
/** | |
* Perform post-registration booting of services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
/** | |
* | |
*/ | |
$namespace = "git-stories"; | |
/** | |
* Package views | |
*/ | |
$this->loadViewsFrom(__DIR__ . '/resources/views', $namespace); | |
if (!$this->app->runningInConsole()) : | |
include_once __DIR__ . '/helper.php'; | |
endif; | |
$this->publish($namespace); | |
} | |
/** | |
* Register any package services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
$this->mergeConfigFrom( | |
__DIR__ . '/config/config.php', 'git-stories' | |
); | |
// $this->app->bind( | |
// '__YOUR_FACADE_NAME__', function () { | |
// return new YOUR_CLASS_NAME(); | |
// }); | |
} | |
private function publish($namespace = 'apps') | |
{ | |
$this->publishes( | |
[ | |
__DIR__ . '/resources/views' => resource_path('views/vendor/' . $namespace), | |
], $namespace . '-views' | |
); | |
/** | |
* Package assets | |
*/ | |
$this->publishes( | |
[ | |
__DIR__ . '/resources/assets/js/' => public_path("assets/{$namespace}/js/"), | |
__DIR__ . '/public/assets/' => public_path('assets/') | |
], $namespace . '-assets' | |
); | |
/** | |
* Package config | |
*/ | |
$this->publishes( | |
[__DIR__ . '/config/config.php' => config_path("{$namespace}.php")], | |
$namespace . '-config' | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment