W3cubDocs

/Symfony 4.1

PhpFileLoader

class PhpFileLoader extends FileLoader

PhpFileLoader loads service definitions from a PHP file.

The PHP file is required and the $container variable can be used within the file to change the container.

Properties

protected $resolver from Loader
static protected $loading from FileLoader
protected $locator from FileLoader
protected $container from FileLoader
protected $isLoadingInstanceof from FileLoader
protected $instanceof from FileLoader

Methods

LoaderResolverInterface getResolver()

Gets the loader resolver.

from Loader
setResolver(LoaderResolverInterface $resolver)

Sets the loader resolver.

from Loader
mixed import(mixed $resource, string|null $type = null, bool $ignoreErrors = false, string|null $sourceResource = null)

Imports a resource.

from FileLoader
$this|LoaderInterface resolve(mixed $resource, string|null $type = null)

Finds a loader able to load an imported resource.

from Loader
__construct(ContainerBuilder $container, FileLocatorInterface $locator) from FileLoader
setCurrentDir(string $dir)

Sets the current directory.

from FileLoader
FileLocatorInterface getLocator()

Returns the file locator used by this loader.

from FileLoader
glob(string $pattern, bool $recursive, $resource = null, bool $ignoreErrors = false) from FileLoader
registerClasses(Definition $prototype, string $namespace, string $resource, string $exclude = null)

Registers a set of classes as services using PSR-4 for discovery.

from FileLoader
setDefinition(string $id, Definition $definition)

Registers a definition in the container with its instanceof-conditionals.

from FileLoader
load(mixed $resource, string|null $type = null)

Loads a resource.

bool supports(mixed $resource, string|null $type = null)

Returns whether this class supports the given resource.

Details

LoaderResolverInterface getResolver()

Gets the loader resolver.

Return Value

LoaderResolverInterface A LoaderResolverInterface instance

setResolver(LoaderResolverInterface $resolver)

Sets the loader resolver.

Parameters

LoaderResolverInterface $resolver

mixed import(mixed $resource, string|null $type = null, bool $ignoreErrors = false, string|null $sourceResource = null)

Imports a resource.

Parameters

mixed $resource A resource
string|null $type The resource type or null if unknown
bool $ignoreErrors Whether to ignore import errors or not
string|null $sourceResource The original resource importing the new resource

Return Value

mixed

Exceptions

FileLoaderLoadException
FileLoaderImportCircularReferenceException
FileLocatorFileNotFoundException

$this|LoaderInterface resolve(mixed $resource, string|null $type = null)

Finds a loader able to load an imported resource.

Parameters

mixed $resource A resource
string|null $type The resource type or null if unknown

Return Value

$this|LoaderInterface

Exceptions

FileLoaderLoadException If no loader is found

__construct(ContainerBuilder $container, FileLocatorInterface $locator)

Parameters

ContainerBuilder $container
FileLocatorInterface $locator

setCurrentDir(string $dir)

Sets the current directory.

Parameters

string $dir

FileLocatorInterface getLocator()

Returns the file locator used by this loader.

Return Value

FileLocatorInterface

protected glob(string $pattern, bool $recursive, $resource = null, bool $ignoreErrors = false)

Parameters

string $pattern
bool $recursive
$resource
bool $ignoreErrors

registerClasses(Definition $prototype, string $namespace, string $resource, string $exclude = null)

Registers a set of classes as services using PSR-4 for discovery.

Parameters

Definition $prototype A definition to use as template
string $namespace The namespace prefix of classes in the scanned directory
string $resource The directory to look for classes, glob-patterns allowed
string $exclude A globed path of files to exclude

protected setDefinition(string $id, Definition $definition)

Registers a definition in the container with its instanceof-conditionals.

Parameters

string $id
Definition $definition

load(mixed $resource, string|null $type = null)

Loads a resource.

Parameters

mixed $resource The resource
string|null $type The resource type or null if unknown

Exceptions

Exception If something went wrong

bool supports(mixed $resource, string|null $type = null)

Returns whether this class supports the given resource.

Parameters

mixed $resource A resource
string|null $type The resource type or null if unknown

Return Value

bool True if this class supports the given resource, false otherwise

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.html