Registers service provider.

This method can be used before or after service container initialization.

@param string|callable $serviceProvider service provider class or callable
437712
public static function registerServiceProvider($serviceProvider)
    {
        if (is_callable($serviceProvider)) {
            $serviceProvider = new CustomServiceProvider($serviceProvider);
        } elseif (!is_a($serviceProvider, ServiceProviderInterface::class, true)) {
            throw new BootstrapException(
                "Error registering service provider: $serviceProvider is not valid service provider."
            );
        }
        if (self::$container === null) {
            self::$serviceProviders[] = $serviceProvider;
        } else {
            /** @var ServiceProviderInterface $provider */
            $provider = new $serviceProvider;
            $provider->register(self::$container);
        }
    }
1317973
protected function bootstrapServiceProviders( $service_providers, Container $container ) {
		foreach ( $service_providers as $provider ) {
			$provider->bootstrap( $container );
		}
	}
386496
public static function addServiceProvider($serviceProviderClassName)
    {
        $appConfigPath = base_path('config/app.php');
        $appConfig = file_get_contents($appConfigPath);
        if (!str_contains($appConfig, $serviceProviderClassName)) {
            $providerEndIndex = strpos($appConfig, "]", strpos($appConfig, " 'providers' => ["));
            $appConfig = substr($appConfig, 0, $providerEndIndex) .
                "    " . $serviceProviderClassName . ",\n    " .
                substr($appConfig, $providerEndIndex);
            file_put_contents($appConfigPath, $appConfig);
        }
    }
324052
protected function registerProviders()
    {
        if (isset($this->container['providers'])) {
            foreach ($this->container['providers'] as $provider) {
                if (!is_subclass_of($provider, ServiceProvider::class)) {
                    throw new UnexpectedValueException($provider .
                        ' must return instance of ' . ServiceProvider::class);
                }

                (new $provider($this))->register();
            }
        }
    }
1293073
public function registerConfiguredProviders()
    {
        foreach ([
                     CacheProvider::class,
                     PartProvider::class,
                     SchedulingProvider::class,
                     ViewProvider::class,
                     EventProvider::class,
                     DatabaseProvider::class,
                     LogProvider::class,
                     HttpProvider::class,
                     SocketProvider::class,

                     ExtendProvider::class,
                 ] as $provider) {
            $this->register($provider);
        }
    }
701662
public function addProvider($provider)
    {
        if (is_string($provider)) {
            $provider = new $provider($this);
        }

        // Only allow a service provider to be registered
        // once.
        if (in_array($provider, $this->providers)) {
            return;
        }

        $this->providers[] = $provider;

        $this->registerEvents($provider);
        $this->registerProvides($provider);

        $this->registerProvider($provider);
    }
708899
public function bootstrap(ServiceProviderInterface $serviceProvider = null)
    {
        $container = $this->createNew(Container::class);

        if (isset($serviceProvider)) {
            $container->registerServices($serviceProvider);    
        }

        $xizlrServiceProvider = $this->createNew(ServiceProvider::class);
        $container->registerServices($xizlrServiceProvider);

        $this->setContainer($container);
    }
176009
public function registerServiceProvider(AbstractServiceProvider $provider, array $values = [])
    {
        $this->container->register($provider->setConsole($this), $values);

        return $this;
    }
925363
public function register(ServiceProviderInterface $provider)
    {
        $provider->register($this);
        $this->providers[get_class($provider)] = $provider;
    }
1026707
public function registerService($serviceKey, ConfigurableService $service, $allowOverride = true)
    {
        if ($allowOverride || ! $this->getServiceLocator()->has($serviceKey)) {
            $this->getServiceManager()->register($serviceKey, $service);
        }
    }
362080
public function registerProvider(DataTablesProviderInterface $provider) {
        if (true === $this->exists($provider->getName())) {
            throw new AlreadyRegisteredDataTablesProviderException($provider->getName());
        }
        $this->index[$provider->getName()] = $this->size();
        return $this->addProvider($provider);
    }
363654
public function registerServices(array $serviceClosureArr) : void
    {
        foreach ($serviceClosureArr as $closure) {
            $reflection = new \ReflectionFunction($closure);
            $arguments  = $reflection->getParameters();
            if (!$closure instanceof \Closure || count($arguments) !== 1) {
                throw new \Exception(
                    "Configuration 'services' definition must be a closure"
                    ." which takes the container as its parameter and also"
                    ." returns it after configuring it."
                );
            }
            $this->container = $closure($this->container);
        }
    }
522654
public function register(ServiceProviderInterface $provider, array $values = [])
    {
        $this->providers[] = $provider;

        parent::register($provider, $values);

        return $this;
    }
896241
protected function registerServiceProvider($serviceProvider) {
        $serviceProvider = $this->ensureProviderIsObject($serviceProvider);

        if (!($serviceProvider instanceof Contracts\ServiceProvider)) {
            throw new InvalidConfigException('Service provider should be an instance of ' . ServiceProvider::class);
        } elseif ($serviceProvider instanceof Contracts\DelayedServiceProvider) {
            $this->addDelayedServiceProvider($serviceProvider);
        } else {
            $serviceProvider->register();
        }
    }
3876
public function addResourceProvider(ResourceProvider $provider)
    {
        $this->loaded && $this->loaded->__invoke();

        $this->resourceProviders[] = $provider;

        return $this;
    }
1285299
public function registerServices(ServiceProviderInterface $serviceProvider)
    {
        $services = $serviceProvider->getServices();      
        foreach ($services as $id => $service) {
            if ($this->has($id) == false) {
                $this->set($id, $service);
            }
        }
    }
760337
public function registerProvider(Provider $provider): self
    {
        $this->providers[$provider->getName()] = $provider;

        return $this;
    }