You are reading the documentation for the 1.x version. Switch to the current version 2.x.

Creation of package

Last updated: Fri, 29 May 2020 14:19

Package class

First step is to create a class who implements Berlioz\Core\Package\PackageInterface interface. To simplify your creation, you can extend Berlioz\Core\Package\AbstractPackage class.

Representation of interface:

/**
 * Interface PackageInterface.
 *
 * @package Berlioz\Core\Package
 */
interface PackageInterface extends CoreAwareInterface
{
    /**
     * Register package.
     *
     * Method called for the registration of all packages.
     * Do not use this method to do any actions on framework, only configuration and registration of services.
     *
     * @return mixed
     */
    public function register();

    /**
     * Init package.
     *
     * Method called after creation of all packages.
     *
     * @return mixed
     */
    public function init();
}

Declaration in composer.json file

Second step is to declare in your composer.json file, that the project is a Berlioz package.

So add "type": "berlioz-package" in your composer.json file. And add in "config" section the declaration of your package class.

Full example of your composer.json file:

{
  "name": "project/my-berlioz-package",
  "type": "berlioz-package",
  ...
  "config": {
    "berlioz": {
      "package": "My\\Project\\BerliozPackage"
    }
  }
}