J
J
JohnxFFF2019-11-14 11:25:57
Composer
JohnxFFF, 2019-11-14 11:25:57

What is extra in Composer json?

Hello, I found this line:

"extra": {
        "bootstrap": "vendor\\mypackage\\Bootstrap"
    },

What is it and why?
I didn't find any clear explanation.
Bootstrap is a regular class that implements an interface:
interface BootstrapInterface{
    public function bootstrap($arg);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2019-11-14
@JohnxFFF

https://getcomposer.org/doc/04-schema.md#extra
Arbitrary extra data for consumption by scripts.
This can be virtually anything.
optional.
In simple terms, this is a section in which you can set your custom parameters that will be used by your scripts or add-ons for Composer. For example, there is a composer/installers plugin that allows you to install packages not in the vendor, but in the right paths for different platforms/CMS. It uses the extra section to configure these paths. For example, for WordPress, it looks like this:

{
  "extra": {
    "wordpress-install-dir": "core",
    "installer-paths": {
      "app/{$name}": ["type:wordpress-dropin"],
      "app/mu-plugins/{$name}": ["type:wordpress-muplugin"],
      "app/plugins/{$name}/": ["type:wordpress-plugin"],
      "app/themes/{$name}/": ["type:wordpress-theme"]
    }
  }
}

G
green_goo, 2019-11-14
@green_goo

https://getcomposer.org/doc/04-schema.md#extra

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question