本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::bind方法的具体用法?PHP Application::bind怎么用?PHP Application::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Foundation\Application
的用法示例。
在下文中一共展示了Application::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bindProductPresenter
/**
* @param string $lang
*/
public function bindProductPresenter($lang)
{
if ($lang == 'zh-tw') {
$this->app->bind(MoneyFormatInterface::class, ProductPresenterZHTW::class);
} elseif ($lang == 'zh-cn') {
$this->app->bind(MoneyFormatInterface::class, ProductPresenterZHCN::class);
} else {
$this->app->bind(MoneyFormatInterface::class, ProductPresenterDefault::class);
}
}
示例2: registerUserVerification
/**
* Register the user verification.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function registerUserVerification(Application $app)
{
$app->bind('user.verification', function ($app) {
return new UserVerification(app()->make('mailer'), app()->make('db')->connection()->getSchemaBuilder());
});
$app->alias('user.verification', UserVerification::class);
}
示例3: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$logger = new Writer(new Monolog($app->environment()), $app['events']);
// Daily files are better for production stuff
$logger->useDailyFiles(storage_path('/logs/laravel.log'));
$app->instance('log', $logger);
// Next we will bind the a Closure to resolve the PSR logger implementation
// as this will grant us the ability to be interoperable with many other
// libraries which are able to utilize the PSR standardized interface.
$app->bind('Psr\\Log\\LoggerInterface', function ($app) {
return $app['log']->getMonolog();
});
$app->bind('Illuminate\\Contracts\\Logging\\Log', function ($app) {
return $app['log'];
});
}
示例4: getDefaultCommands
/**
* Initializes all the commands default
*/
protected function getDefaultCommands()
{
$commands = parent::getDefaultCommands();
$commands[] = new Command\AboutCommand($this->app);
$commands[] = new Command\StopCommand($this->app);
// Comandos da aplicacao
$cmds = config('app.commands', []);
foreach ($cmds as $cid => $cClass) {
$cid = sprintf('command.%s', $cid);
$this->app->bind($cid, $cClass);
$commands[] = $this->app[$cid];
}
// verificar se deve incluir o comando make:command
if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\MakeCommand')) {
$commands[] = new \Consolle\Command\MakeCommand($this->app);
}
// verificar se deve incluir o comando optimize
if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\OptimizeCommand')) {
$commands[] = new \Consolle\Command\OptimizeCommand($this->app);
}
// verificar se deve incluir o comando self-compiler
if ('phar:' !== substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\SelfCompilerCommand')) {
$commands[] = new \Consolle\Command\SelfCompilerCommand($this->app);
}
// Verificar se deve incluir o comando self-update
if ('phar:' === substr(__FILE__, 0, 5) && class_exists('\\Consolle\\Command\\SelfCompilerCommand') && file_exists(base_path('update.json'))) {
$commands[] = new \Consolle\Command\SelfUpdateCommand($this->app);
}
return $commands;
}
示例5: registerBindings
/**
* Register the bindings.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function registerBindings(Application $app)
{
$app->bind('cachet.connection', function ($app) {
$manager = $app['cachet'];
return $manager->connection();
});
$app->alias('cachet.connection', CachetConnection::class);
}
示例6: registerBindings
/**
* Register the bindings.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function registerBindings(Application $app)
{
$app->bind('telegram.bot', function ($app) {
$manager = $app['telegram'];
return $manager->bot();
});
$app->alias('telegram.bot', Api::class);
}
示例7: setupBinds
/**
* Binds all interfaces to the IOC container
*/
protected function setupBinds()
{
/*
* Tenant repository
*/
$this->app->bind('HynMe\\MultiTenant\\Contracts\\TenantRepositoryContract', function () {
return new TenantRepository(new Tenant());
});
/*
* Tenant hostname repository
*/
$this->app->bind('HynMe\\MultiTenant\\Contracts\\HostnameRepositoryContract', function () {
return new HostnameRepository(new Hostname());
});
/*
* Tenant website repository
*/
$this->app->bind('HynMe\\MultiTenant\\Contracts\\WebsiteRepositoryContract', function ($app) {
return new WebsiteRepository(new Website(), $this->app->make('HynMe\\MultiTenant\\Contracts\\HostnameRepositoryContract'));
});
}
示例8: runMigrations
protected function runMigrations()
{
$this->application->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
});
$migrator = $this->application->make('Flarum\\Database\\Migrator');
$migrator->getRepository()->createRepository();
$migrator->run(__DIR__ . '/../../../migrations');
foreach ($migrator->getNotes() as $note) {
$this->info($note);
}
}
示例9: register
/**
* Registers the server in the container.
*
* @return \Illuminate\Foundation\Application
* @throws \Exception
*/
public function register()
{
// Auto register the support service provider
if (!get_class($this) == SupportServiceProvider::class) {
$this->app->register(SupportServiceProvider::class);
}
$this->viewsPath = Str::replace($this->viewsPath, '{resourcesPath}', $this->getResourcesPath());
$this->assetsPath = Str::replace($this->assetsPath, '{resourcesPath}', $this->getResourcesPath());
$router = $this->app->make('router');
$kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
$this->registerConfigFiles();
foreach ($this->prependMiddleware as $middleware) {
$kernel->prependMiddleware($middleware);
}
foreach ($this->middleware as $middleware) {
$kernel->pushMiddleware($middleware);
}
foreach ($this->routeMiddleware as $key => $middleware) {
$router->middleware($key, $middleware);
}
foreach ($this->providers as $provider) {
$this->app->register($provider);
}
foreach ($this->deferredProviders as $provider) {
$this->app->registerDeferredProvider($provider);
}
foreach ($this->bindings as $binding => $class) {
$this->app->bind($binding, $class);
}
foreach ($this->singletons as $binding => $class) {
if ($this->strict && !class_exists($class) && !interface_exists($class)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->singleton($binding, $class);
}
foreach ($this->aliases as $alias => $full) {
if ($this->strict && !class_exists($full) && !interface_exists($full)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->alias($alias, $full);
}
if (is_array($this->commands) and count($this->commands) > 0) {
$this->commands($this->commands);
}
AliasLoader::getInstance($this->facades)->register();
$this->requireHelpersFor('register');
return $this->app;
}
示例10: mockBoundCoreExternalComponents
/**
* Mocks components that should not be part of any core test.
*
* @param Application $app
* @return $this
*/
protected function mockBoundCoreExternalComponents(Application $app)
{
$app->bind('mock-cms-auth', function () {
$mock = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
$mock->method('version')->willReturn('1.2.3');
$mock->method('getRouteLoginAction')->willReturn('MockController@index');
$mock->method('getRouteLoginPostAction')->willReturn('MockController@index');
$mock->method('getRouteLogoutAction')->willReturn('MockController@index');
$mock->method('getRoutePasswordEmailGetAction')->willReturn('MockController@index');
$mock->method('getRoutePasswordEmailPostAction')->willReturn('MockController@index');
$mock->method('getRoutePasswordResetGetAction')->willReturn('MockController@index');
$mock->method('getRoutePasswordResetPostAction')->willReturn('MockController@index');
return $mock;
});
return $this;
}
示例11: handle
/**
* Handle the command.
*
* @param Application $application
*/
public function handle(Application $application, Laravel $laravel)
{
$app = env('APPLICATION_REFERENCE', 'default');
if (PHP_SAPI == 'cli') {
$app = (new ArgvInput())->getParameterOption('--app', $app);
$laravel->bind('path.public', function () use($laravel) {
if ($path = env('PUBLIC_PATH')) {
return base_path($path);
}
// Check default path.
if (file_exists($path = base_path('public/index.php'))) {
return dirname($path);
}
// Check common alternative.
if (file_exists($path = base_path('public_html/index.php'))) {
return dirname($path);
}
return base_path('public');
});
}
/*
* Set the reference to our default first.
* When in a dev environment and working
* with Artisan this the same as locating.
*/
$application->setReference($app);
/*
* If the application is installed
* then locate the application and
* initialize.
*/
if ($application->isInstalled()) {
if (env('DB_CONNECTION', env('DB_DRIVER'))) {
$application->locate();
$application->setup();
}
return;
}
/*
* If we're not installed just
* assume default for now.
*/
$application->setReference('default');
}
示例12: registerBindings
/**
* Register the bindings.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function registerBindings(Application $app)
{
$app->bind('pusher.connection', function ($app) {
$manager = $app['pusher'];
return $manager->connection();
});
$app->alias('pusher.connection', Pusher::class);
}
示例13: bindClasses
/**
* Bind addon classes.
*
* @param AddonServiceProvider $provider
*/
protected function bindClasses(AddonServiceProvider $provider)
{
foreach ($provider->getBindings() as $abstract => $concrete) {
$this->application->bind($abstract, $concrete);
}
}
示例14: registerBindings
/**
* Register the bindings.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function registerBindings(Application $app)
{
$app->bind('mailchimp.connection', function ($app) {
$manager = $app['mailchimp'];
return $manager->connection();
});
$app->alias('mailchimp.connection', Mailchimp::class);
}
示例15: registerInterfaceBindings
/**
* Bind the interfaces to their implementations.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
public function registerInterfaceBindings(Application $app)
{
$app->bind(ClientInterface::class, FluentClient::class);
$app->bind(ScopeInterface::class, FluentScope::class);
$app->bind(SessionInterface::class, FluentSession::class);
$app->bind(AuthCodeInterface::class, FluentAuthCode::class);
$app->bind(AccessTokenInterface::class, FluentAccessToken::class);
$app->bind(RefreshTokenInterface::class, FluentRefreshToken::class);
}