Last active
October 27, 2020 06:09
-
-
Save richnicholls404/7449378 to your computer and use it in GitHub Desktop.
Register Service Provider and assign a Facade alias programatically in Laravel (such as inside a package)
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 Cavedwellerrich\MyPackage; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\Foundation\AliasLoader; | |
class MyPackageServiceProvider extends ServiceProvider { | |
//... | |
public function register() | |
{ | |
//call sentry's service provider | |
$this->app->register('Cartalyst\Sentry\SentryServiceProvider'); | |
//set up facade | |
AliasLoader::getInstance()->alias('Sentry', 'Cartalyst\Sentry\Facades\Laravel\Sentry'); | |
//bind mypackage class | |
$this->app->bind('mypackage', function() | |
{ | |
return new MyPackage; | |
}); | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Might that
AliasLoader::getInstance()->alias('Sentry', 'Cartalyst\Sentry\Facades\Laravel\Sentry');
use as$this->app->alias('Sentry', 'Cartalyst\Sentry\Facades\Laravel\Sentry');
?