当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::bind方法代码示例

本文整理汇总了PHP中Illuminate\Container\Container::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::bind方法的具体用法?PHP Container::bind怎么用?PHP Container::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Container\Container的用法示例。


在下文中一共展示了Container::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createApplicationContainer

 protected function createApplicationContainer()
 {
     $this->app = new \TestContainer();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->registerConfigure();
     $eventServiceProvider = new \Illuminate\Encryption\EncryptionServiceProvider($this->app);
     $eventServiceProvider->register();
     $eventServiceProvider = new \Illuminate\Events\EventServiceProvider($this->app);
     $eventServiceProvider->register();
     $queueProvider = new \Illuminate\Queue\QueueServiceProvider($this->app);
     $queueProvider->register();
     $sessionProvider = new \Illuminate\Session\SessionServiceProvider($this->app);
     $sessionProvider->register();
     $this->registerDatabase();
     $this->registerCache();
     $couchbaseProvider = new \Ytake\LaravelCouchbase\CouchbaseServiceProvider($this->app);
     $couchbaseProvider->register();
     $couchbaseProvider->boot();
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     (new \Illuminate\Events\EventServiceProvider($this->app))->register();
     \Illuminate\Container\Container::setInstance($this->app);
 }
开发者ID:ytake,项目名称:laravel-couchbase,代码行数:26,代码来源:CouchbaseTestCase.php

示例2: getContainer

 /**
  * @return \Illuminate\Container\Container
  */
 public static function getContainer()
 {
     if (!self::$container) {
         self::$container = new \Illuminate\Container\Container();
         self::$container->bind('app', self::$container);
     }
     return self::$container;
 }
开发者ID:osotov,项目名称:illuminate-for-bitrix,代码行数:11,代码来源:Container.php

示例3: init

 public function init()
 {
     $builder = new Container();
     $builder->bind('bicycle_factory_shared', function ($app) {
         return new \PhpBench\Benchmarks\Container\Acme\BicycleFactory();
     }, true);
     $builder->bind('bicycle_factory', function ($app) {
         return new \PhpBench\Benchmarks\Container\Acme\BicycleFactory();
     }, false);
     $this->container = $builder;
 }
开发者ID:phpbench,项目名称:benchmarks-containers,代码行数:11,代码来源:IlluminateBench.php

示例4: registerRepositories

 /**
  * Register repositories Interfaces
  *
  * @return void
  */
 public function registerRepositories()
 {
     //Bind UserRepository interface
     $this->ioc->bind('App\\Repositories\\Contracts\\UserRepositoryInterface', 'App\\Repositories\\UserRepository');
     $this->ioc->bind('UserRepo', function ($app) {
         return $app->make('App\\Repositories\\Contracts\\UserRepositoryInterface');
     });
     //Bind PostRepository interface
     $this->ioc->bind('App\\Repositories\\Contracts\\PostRepositoryInterface', 'App\\Repositories\\PostRepository');
     $this->ioc->bind('PostRepo', function ($app) {
         return $app->make('App\\Repositories\\Contracts\\PostRepositoryInterface');
     });
 }
开发者ID:AshniSukhoo,项目名称:UOM_connect,代码行数:18,代码来源:Bootioc.php

示例5: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $app = new Container();
     $app->bind('config', function () {
         return Mockery::mock('config', function ($mock) {
             $mock->shouldReceive('get')->with('config.image_engine', '')->andReturn('Gd');
             $mock->shouldReceive('get')->with('config.quality', '')->andReturn(75);
             $mock->shouldReceive('get')->with('config.cache_folder', '')->andReturn('');
         });
     });
     $app['path.public'] = 'tests/public';
     $app->bind('illuminage', function ($app) {
         return new \Illuminage\Illuminage($app);
     });
     Illuminage::setFacadeApplication($app);
 }
开发者ID:Daegon,项目名称:illuminage,代码行数:16,代码来源:_start.php

示例6: register

 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('campfire', function ($app) {
         return new Campfire($app['config']->get('rocketeer-campfire::config'));
     });
     return $app;
 }
开发者ID:anahkiasen,项目名称:rocketeer-campfire,代码行数:14,代码来源:RocketeerCampfire.php

示例7: register

 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('newrelic', function ($app) {
         return new RocketeerNewrelicConfig($app['config']->get('rocketeer-newrelic::config'));
     });
     return $app;
 }
开发者ID:houseofdross,项目名称:rocketeer-newrelic,代码行数:14,代码来源:RocketeerNewrelic.php

示例8: applyType

 /**
  * Apply various parameters according to form type
  *
  * @param  string $type The original form type provided
  *
  * @return string The final form type
  */
 private function applyType($type)
 {
     // If classic form
     if ($type == 'open') {
         return $this->app['former']->getOption('default_form_type');
     }
     // Look for HTTPS form
     if (Str::contains($type, 'secure')) {
         $type = str_replace('secure', '', $type);
         $this->secure = true;
     }
     // Look for file form
     if (Str::contains($type, 'for_files')) {
         $type = str_replace('for_files', '', $type);
         $this->attributes['enctype'] = 'multipart/form-data';
     }
     // Calculate form type
     $type = str_replace('open', '', $type);
     $type = trim($type, '_');
     // If raw form
     if ($type == 'raw') {
         $this->app->bind('former.form.framework', function ($app) {
             return $app['former']->getFrameworkInstance('Nude');
         });
     }
     // Use default form type if the one provided is invalid
     if ($type !== 'raw' and !in_array($type, $this->app['former.form.framework']->availableTypes())) {
         $type = $this->app['former']->getOption('default_form_type');
     }
     return $type;
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:38,代码来源:Form.php

示例9: register

 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('slack', function ($app) {
         return new Client($app['config']->get('rocketeer-slack::url'));
     });
     return $app;
 }
开发者ID:anahkiasen,项目名称:rocketeer-slack,代码行数:14,代码来源:RocketeerSlack.php

示例10: createContainer

 /**
  * @return ContainerInterface
  */
 private function createContainer(array $map = [])
 {
     $container = new Container();
     foreach ($map as $key => $value) {
         $container->bind($key, $value);
     }
     return new LaravelContainer($container);
 }
开发者ID:bweston92,项目名称:monii-container-interop-laravel,代码行数:11,代码来源:LaravelContainerTest.php

示例11: register

 public function register(Container $app)
 {
     $settings = ['username' => $app['config']->get('rocketeer-slack-unofficial::config')['url'], 'channel' => $app['config']->get('rocketeer-slack-unofficial::config')['channel'], 'link_names' => true, 'icon' => ':rocket:'];
     $app->bind('slack', function ($app) use($settings) {
         return new Client($app['config']->get('rocketeer-slack-unofficial::config')['hook-url'], $settings);
     });
     return $app;
 }
开发者ID:netoholic,项目名称:rocketeer-slack-unofficial,代码行数:8,代码来源:RocketeerSlack.php

示例12: registerViewFinder

 /**
  * Register the view finder implementation.
  *
  * @return void
  */
 public function registerViewFinder()
 {
     $me = $this;
     $this->container->bind('view.finder', function ($app) use($me) {
         $paths = $me->viewPaths;
         return new FileViewFinder($app['files'], $paths);
     });
 }
开发者ID:polaris64,项目名称:Laravel-Blade,代码行数:13,代码来源:Blade.php

示例13: shared

 /**
  * Shared is a pseudonym for `bind()` as singleton.
  *
  * @param      $abstract
  * @param null $concrete
  *
  * @return void
  */
 public function shared($abstract, $concrete = NULL)
 {
     // translate ['alias','concrete'] to ['alias'=>'concrete'] for embedded DI
     if (is_array($abstract)) {
         $abstract = [$abstract[0] => $abstract[1]];
     }
     static::$container->bind($abstract, $concrete, TRUE);
 }
开发者ID:anctemarry27,项目名称:cogs,代码行数:16,代码来源:Forge.php

示例14: bind

 /**
  * Overload the bind method so the services are added to the Slim DI container as well as Illuminate container
  */
 public function bind($abstract, $concrete = null, $shared = false)
 {
     parent::bind($abstract, $concrete, $shared);
     $service_manager = $this;
     $this->app->{$abstract} = function () use($service_manager, $abstract) {
         return $service_manager->make($abstract);
     };
 }
开发者ID:efracuadras,项目名称:slimgeek,代码行数:11,代码来源:Application.php

示例15: testAliases

 public function testAliases()
 {
     $container = new Container();
     $container->bind('request', function () {
         return 'input';
     });
     $container->bind('translator', function () {
         return 'lang';
     });
     $container->bind('blade.compiler', function () {
         return 'blade';
     });
     Container::setInstance($container);
     $this->assertEquals('input', $this->input);
     $this->assertEquals('lang', $this->lang);
     $this->assertEquals('blade', $this->blade_compiler);
     $this->assertSame($container, $this->app);
 }
开发者ID:cknow,项目名称:laravel-support,代码行数:18,代码来源:LaravelTraitTest.php


注:本文中的Illuminate\Container\Container::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。