CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
      • Argument
      • Attribute
      • Definition
      • Exception
      • Inflector
      • ServiceProvider
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class ServiceProvider

Container ServiceProvider

Service provider bundle related services together helping to organize your application's dependencies. They also help improve performance of applications with many services by allowing service registration to be deferred until services are needed.

Abstract
Namespace: Cake\Container

Property Summary

  • $container protected
    Cake\Container\ContainerInterface|null
  • $identifier protected
    string|null
  • $provides protected
    array<string>

    List of ids of services this provider provides.

Method Summary

  • boot() public

    Delegate to the bootstrap() method

    This method wraps the underlying container's boot() function so users only need to use the CakePHP bootstrap() interface.

  • bootstrap() public

    Bootstrap hook for ServiceProviders

    This hook should be implemented if your service provider needs to register additional service providers, load configuration files or do any other work when the service provider is added to the container.

  • getContainer() public
  • getIdentifier() public
  • provides() public

    The provides method is a way to let the container know that a service is provided by this service provider.

    Every service registered via this service provider must have an alias added to this array or it will be ignored.

  • register() public

    Call the abstract services() method.

    This method primarily exists as a shim between the interface that the underlying container has and the one we want to offer in CakePHP.

  • services() abstract public

    Register the services in a provider.

    All services registered in this method should also be included in the $provides property so that services can be located.

  • setContainer() public
  • setIdentifier() public

Method Detail

boot() ¶ public

boot(): void

Delegate to the bootstrap() method

This method wraps the underlying container's boot() function so users only need to use the CakePHP bootstrap() interface.

Returns
void

bootstrap() ¶ public

bootstrap(Cake\Container\ContainerInterface $container): void

Bootstrap hook for ServiceProviders

This hook should be implemented if your service provider needs to register additional service providers, load configuration files or do any other work when the service provider is added to the container.

Parameters
Cake\Container\ContainerInterface $container

The container to add services to.

Returns
void

getContainer() ¶ public

getContainer(): Cake\Container\ContainerInterface
Returns
Cake\Container\ContainerInterface

getIdentifier() ¶ public

getIdentifier(): string
Returns
string

provides() ¶ public

provides(string $id): bool

The provides method is a way to let the container know that a service is provided by this service provider.

Every service registered via this service provider must have an alias added to this array or it will be ignored.

Parameters
string $id

Identifier.

Returns
bool

register() ¶ public

register(): void

Call the abstract services() method.

This method primarily exists as a shim between the interface that the underlying container has and the one we want to offer in CakePHP.

Returns
void

services() ¶ abstract public

services(Cake\Container\ContainerInterface $container): void

Register the services in a provider.

All services registered in this method should also be included in the $provides property so that services can be located.

Parameters
Cake\Container\ContainerInterface $container

The container to add services to.

Returns
void

setContainer() ¶ public

setContainer(Cake\Container\ContainerInterface $container): $this
Parameters
Cake\Container\ContainerInterface $container
Returns
$this

setIdentifier() ¶ public

setIdentifier(string $id): $this
Parameters
string $id
Returns
$this

Property Detail

$container ¶ protected

Type
Cake\Container\ContainerInterface|null

$identifier ¶ protected

Type
string|null

$provides ¶ protected

List of ids of services this provider provides.

Type
array<string>
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs