php-cooper-symfony

CooperKernelTrait

A `MicroKernelTrait` kernel's configuration, CASC in place of `config/packages/*.yaml`:

final class Kernel extends BaseKernel
{
    use MicroKernelTrait, CooperKernelTrait {
        CooperKernelTrait::configureContainer insteadof MicroKernelTrait;
    }
}

configureContainer() loads config/config.casc -- bundle configuration and parameters, see CascFileLoader -- and then the services exactly as MicroKernelTrait does: config/services.yaml and config/services_<env>.yaml, else their .php counterparts. Service wiring stays Symfony's. config/packages/ is not read.

The .casc loader is also added to the kernel's loader resolver, so a kernel with its own configureContainer() can call importCooperConfiguration() itself, or import a .casc file the way it imports any other.

insteadof is the one line of glue PHP asks for: both traits define configureContainer(), and PHP will not pick one silently.

Table of Contents

Methods

cooperDocument()  : string
The CASC document: `config/config.casc` in the project. Override to keep it elsewhere.
cooperOptions()  : array<string, mixed>
Cooper's load options -- `resolvers`, `tags`, `modules`, `importSchemes`, the `.env` options -- for an application that needs any. Override to give some; none by default.
importCooperConfiguration()  : void
Registers the `.casc` loader with `$loader`'s resolver and loads `cooperDocument()` into `$builder`.
configureContainer()  : void
Loads the CASC document, then the services as `MicroKernelTrait` does.
hasCascLoader()  : bool

Methods

cooperDocument()

The CASC document: `config/config.casc` in the project. Override to keep it elsewhere.

protected cooperDocument() : string
Return values
string —

an absolute path

cooperOptions()

Cooper's load options -- `resolvers`, `tags`, `modules`, `importSchemes`, the `.env` options -- for an application that needs any. Override to give some; none by default.

protected cooperOptions() : array<string, mixed>
Return values
array<string, mixed>

importCooperConfiguration()

Registers the `.casc` loader with `$loader`'s resolver and loads `cooperDocument()` into `$builder`.

protected importCooperConfiguration(LoaderInterface $loader, ContainerBuilder $builder) : void
Parameters
$loader : LoaderInterface

the kernel's loader

$builder : ContainerBuilder

the container being built

configureContainer()

Loads the CASC document, then the services as `MicroKernelTrait` does.

private configureContainer(ContainerConfigurator $container, LoaderInterface $loader, ContainerBuilder $builder) : void
Parameters
$container : ContainerConfigurator

the configurator for the services

$loader : LoaderInterface

the kernel's loader

$builder : ContainerBuilder

the container being built

hasCascLoader()

private static hasCascLoader(LoaderResolver $resolver) : bool
Parameters
$resolver : LoaderResolver
Return values
bool
On this page

Search results