1. Home
  2. Docs
  3. Developers
  4. Develop custom packages
  5. Registering your package

Registering your package

Registering a package is simple.

Create an instance of \Convo\Core\Factory\PackageDescriptor. This class takes two arguments with an optional third.

  1. A reference to a \Psr\Container\ContainerInterface
  2. A string name with a fully qualified package class of the package you’re registering, e.g. ‘\Convo\Pckg\Core\CorePackageDefinition
  3. (Optional) A callable instantiation function. You may tell the descriptor how to exactly instantiate your package. This is useful if you need to do any prior work on the arguments your package takes. This method must return \Convo\Core\Factory\IPackageDefinition

If you do not provide a custom instantiation function, then the descriptor will use reflection to check your package’s constructor arguments. For each argument, it will first attempt to extract data from the container based on the argument’s name. If that fails, then the class of the argument is taken and then the container is checked if it contains an entry under the key of the class’ name. Should this fail as well, the descriptor will throw an exception because the package cannot be instantiated. In this case, you should provide a custom function.

TODO: explain how/where to register

Was this article helpful to you? Yes No

How can we help?