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


PHP Container::instance方法代码示例

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


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

示例1: setupContainer

 /**
  * Setup the IoC container instance.
  *
  * @param  \Illuminate\Container\Container|null  $container
  * @return void
  */
 protected function setupContainer($container)
 {
     $this->container = $container ?: new Container();
     if (!$this->container->bound('config')) {
         $this->container->instance('config', new Fluent());
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:13,代码来源:CapsuleManagerTrait.php

示例2: it_should_not_affect_parent_container

 /**
  * @test
  */
 public function it_should_not_affect_parent_container()
 {
     $this->parent->instance('a', 1);
     $this->local->instance('a', 2);
     $this->local->instance('b', 3);
     $this->assertTrue($this->parent->bound('a'));
     $this->assertEquals(1, $this->parent->make('a'));
     $this->assertFalse($this->parent->bound('b'));
     $this->assertEquals(2, $this->local->make('a'));
     $this->assertEquals(3, $this->local->make('b'));
 }
开发者ID:e1stuff,项目名称:layered-laravel-container,代码行数:14,代码来源:LayeredContainerTest.php

示例3: setUp

 /**
  * Set up the tests
  */
 public function setUp()
 {
     date_default_timezone_set('Europe/London');
     // Create container
     $this->app = new Container();
     $provider = new EventServiceProvider($this->app);
     $provider->register();
     // Bind mocked instances into it
     $this->app['config'] = $this->mockConfig();
     $this->app->instance('request', $this->mockRequest());
     $this->app['translation.loader'] = Mockery::mock('Illuminate\\Translation\\FileLoader');
     $this->app->instance('Illuminate\\Container\\Container', $this->app);
 }
开发者ID:anahkiasen,项目名称:polyglot,代码行数:16,代码来源:ContainerTestCase.php

示例4: setUp

 /**
  * Set up the tests
  *
  * @return void
  */
 public function setUp()
 {
     $this->app = new Container();
     // Laravel classes --------------------------------------------- /
     $this->app->instance('path.base', '/src');
     $this->app->instance('path', '/src/app');
     $this->app->instance('path.public', '/src/public');
     $this->app->instance('path.storage', '/src/app/storage');
     $this->app['files'] = new Filesystem();
     $this->app['config'] = $this->getConfig();
     // Trucker classes ------------------------------------------- /
     $serviceProvider = new TruckerServiceProvider($this->app);
     $this->app = $serviceProvider->bindClasses($this->app);
 }
开发者ID:summer11123,项目名称:trucker,代码行数:19,代码来源:_start.php

示例5: loadExternalConfig

 /**
  * Load the external config files specified by the command line option.
  */
 protected function loadExternalConfig()
 {
     $config = new Repository(static::getDefaultConfig());
     $filesystem = new Filesystem();
     foreach ($this->getConfigFiles($filesystem) as $filename) {
         $this->output->writeln("<info>Reading config from <path>{$filename}</path></info>");
         if ($filesystem->extension($filename) == 'php') {
             $configValues = $filesystem->getRequire($filename);
         } else {
             $configValues = Yaml::parse($filesystem->get($filename));
         }
         $config->set(array_dot($configValues));
     }
     $this->container->instance('config', $config);
 }
开发者ID:parsnick,项目名称:steak,代码行数:18,代码来源:Application.php

示例6: setRoutes

 /**
  * Set the route collection instance.
  *
  * @param  \Illuminate\Routing\RouteCollection  $routes
  * @return void
  */
 public function setRoutes(RouteCollection $routes)
 {
     foreach ($routes as $route) {
         $route->setRouter($this)->setContainer($this->container);
     }
     $this->routes = $routes;
     $this->container->instance('routes', $this->routes);
 }
开发者ID:samlev,项目名称:framework,代码行数:14,代码来源:Router.php

示例7: toMacros

 /**
  * Dispatch a call to a registered macro
  *
  * @param  string $method       The macro's name
  * @param  array  $parameters   The macro's arguments
  *
  * @return mixed
  */
 public function toMacros($method, $parameters)
 {
     if (!$this->app['former']->hasMacro($method)) {
         return false;
     }
     // Get and format macro
     $callback = $this->app['former']->getMacro($method);
     if ($callback instanceof Closure) {
         return call_user_func_array($callback, $parameters);
     } elseif (!is_string($callback)) {
         return false;
     }
     // Get class and method
     list($class, $method) = explode('@', $callback);
     $this->app->instance('Illuminate\\Container\\Container', $this->app);
     return call_user_func_array(array($this->app->make($class), $method), $parameters);
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:25,代码来源:MethodDispatcher.php

示例8: resolveController

 /**
  * Resolve a controller from the container.
  *
  * @param string $class
  *
  * @return \Illuminate\Routing\Controller
  */
 protected function resolveController($class)
 {
     $controller = $this->container->make($class);
     if (!$this->container->bound($class)) {
         $this->container->instance($class, $controller);
     }
     return $controller;
 }
开发者ID:jacobDaeHyung,项目名称:api,代码行数:15,代码来源:ControllerReviser.php

示例9: createContainer

 protected function createContainer()
 {
     $container = new Container();
     $container->instance('array_iterator', new \ArrayIterator(range(1, 5)));
     $container->bind('error', function () {
         throw new \RuntimeException();
     });
     return new LaravelContainerAdapter($container);
 }
开发者ID:hoesler,项目名称:acclimate-container,代码行数:9,代码来源:LaravelContainerAdapterTest.php

示例10: setUp

 /**
  * Set up the tests
  *
  * @return void
  */
 public function setUp()
 {
     $this->app = new Container();
     // Laravel classes --------------------------------------------- /
     $this->app->instance('path.base', '/src');
     $this->app->instance('path', '/src/app');
     $this->app->instance('path.public', '/src/public');
     $this->app->instance('path.storage', '/src/app/storage');
     $this->app['files'] = new Filesystem();
     $this->app['config'] = $this->getConfig();
     $this->app['remote'] = $this->getRemote();
     $this->app['artisan'] = $this->getArtisan();
     $this->app['rocketeer.command'] = $this->getCommand();
     // Rocketeer classes ------------------------------------------- /
     $serviceProvider = new RocketeerServiceProvider($this->app);
     $this->app = $serviceProvider->bindPaths($this->app);
     $this->app = $serviceProvider->bindCoreClasses($this->app);
     $this->app = $serviceProvider->bindClasses($this->app);
     $this->app = $serviceProvider->bindScm($this->app);
 }
开发者ID:denji,项目名称:rocketeer,代码行数:25,代码来源:ContainerTestCase.php

示例11: createApplicationContainer

 protected function createApplicationContainer()
 {
     $this->app = new \Illuminate\Container\Container();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->app->instance('log', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->app->instance('Psr\\Log\\LoggerInterface', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->registerConfigure();
     $this->registerDatabase();
     $this->registerCache();
     $annotationConfiguration = new \Ytake\LaravelAspect\AnnotationConfiguration($this->app['config']->get('ytake-laravel-aop.annotation'));
     $annotationConfiguration->ignoredAnnotations();
     $this->app->singleton('aspect.manager', function ($app) {
         return new \Ytake\LaravelAspect\AspectManager($app);
     });
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     \Illuminate\Container\Container::setInstance($this->app);
 }
开发者ID:ytake,项目名称:laravel-aspect,代码行数:21,代码来源:AspectTestCase.php

示例12: getController

 /**
  * Get the routes controller instance.
  *
  * @return mixed
  */
 public function getController()
 {
     if (!isset($this->action['uses']) || !is_string($this->action['uses'])) {
         return;
     } elseif (isset($this->controller)) {
         return $this->controller;
     }
     if (Str::contains($this->action['uses'], '@')) {
         list($controller, $this->method) = explode('@', $this->action['uses']);
         $this->container->instance($controller, $this->controller = $this->container->make($controller));
         return $this->controller;
     }
 }
开发者ID:lengdelong,项目名称:api,代码行数:18,代码来源:Route.php

示例13: testDispatchShouldCallAfterResolvingIfCommandNotQueued

 public function testDispatchShouldCallAfterResolvingIfCommandNotQueued()
 {
     $container = new Container();
     $handler = m::mock('StdClass')->shouldIgnoreMissing();
     $handler->shouldReceive('after')->once();
     $container->instance('Handler', $handler);
     $dispatcher = new Dispatcher($container);
     $dispatcher->mapUsing(function () {
         return 'Handler@handle';
     });
     $dispatcher->dispatch(new BusDispatcherTestBasicCommand(), function ($handler) {
         $handler->after();
     });
 }
开发者ID:jonathantorres,项目名称:bus,代码行数:14,代码来源:BusDispatcherTest.php

示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $app = new Container();
     $app->instance('config', new Repository());
     (new EventServiceProvider($app))->register();
     (new AmiServiceProvider($app))->register();
     $this->loop = $app[LoopInterface::class];
     $this->loop->nextTick(function () {
         if (!$this->running) {
             $this->loop->stop();
         }
     });
     $this->stream = $app[Stream::class];
     $this->events = $app['events'];
     $this->app = $app;
 }
开发者ID:enniel,项目名称:ami,代码行数:19,代码来源:TestCase.php

示例15: bindConfiguration

 /**
  * Bind paths to the configuration files
  *
  * @return void
  */
 protected function bindConfiguration()
 {
     $path = $this->getBasePath();
     $logs = $this->getStoragePath();
     // Prepare the paths to bind
     $paths = array('config' => '.rocketeer', 'events' => '.rocketeer/events', 'tasks' => '.rocketeer/tasks', 'logs' => $logs . '/logs');
     foreach ($paths as $key => $file) {
         $filename = $path . $file;
         // Check whether we provided a file or folder
         if (!is_dir($filename) and file_exists($filename . '.php')) {
             $filename .= '.php';
         }
         // Use configuration in current folder if none found
         $realpath = realpath('.') . '/' . $file;
         if (!file_exists($filename) and file_exists($realpath)) {
             $filename = $realpath;
         }
         $this->app->instance('path.rocketeer.' . $key, $filename);
     }
 }
开发者ID:denji,项目名称:rocketeer,代码行数:25,代码来源:Igniter.php


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