Download the PHP package thecodingmachine/yaco without Composer
On this page you can find all versions of the php package thecodingmachine/yaco. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thecodingmachine/yaco
More information about thecodingmachine/yaco
Files in thecodingmachine/yaco
Package yaco
Short Description YACO (Yet Another COmpiler) is a PHP tool that generates a PHP container based on entry definitions.
License MIT
Informations about the package yaco
YACO - Yet another compiler
YACO (Yet Another COmpiler) is a PHP tool that generates a PHP container based on entry definitions. It is fully compatible with entry definitions from definition-interop.
Installation
You can install this package through Composer:
The packages adheres to the SemVer specification, and there will be full backward compatibility between minor versions.
Usage
This package contains a Compiler
class. The goal of this class is to take a number of "entry definitions"
(as defined in definition-interop) and to transform those
into a PHP class that implements the ContainerInterface
Now, you can instantiate your container using this code:
Note: Yaco is consuming container definitions (implementing Interop\Container\Definition\DefinitionInterface
).
Out of the box, Yaco does not provide any classes implementing this interface.
However, you can find such classes in a package like mnapoli/assembly.
Here is a complete sample using Yaco and Assembly:
Compile phase:
Usage:
Note: the My\Container
class implements the Interop\Container\ContainerInterface
. Therefore, it can be used with any framework compatible with container-interop.
Service provider support
This package supports container agnostic service providers as defined in container-interop/service-provider.
To register service providers, you must pass to the compiler a TheCodingMachine\ServiceProvider\Registry
object.
Here is a sample:
Important! When you want to use the compiled container, you have to pass a registry containing the same service providers, in the same order.
Below is an instantiation of the container generated by the code above:
Miscellaneous
Delegate lookup support
Containers generated by Yaco support the "delegate lookup" feature of container-interop.
If you pass a container as the second argument to the generated container, all dependency lookups will be done on the passed container rather than on the generated container.
Here is a sample:
Definition providers
You can directly register a definition provider using the register
method:
Definition providers are classes implementing the Interop\Container\Definition\DefinitionProviderInterface
.
They provide a list of container definitions to be compiled by the compiler.
All versions of yaco with dependencies
container-interop/container-interop Version ^1.0
jeremeamia/superclosure Version ^2.0
mouf/picotainer Version ^1.0