Frage

I'm creating a package for composer, and I'm wanting to (from inside a class in my package) check if a configuration option exists, and if not set a default.

Is there a best practice etc for package configuration (or is that done in composer.json)? I couldnt find anything on composers website. As in, is there a standard, like all apps should put key=>value pairs into an app/confg.php file for composer packages to use or anything like that?

Or should the package just document how to configure, seems like there would be a standard of some sorts so all packages aren't using different config methods

Usage: building a command line app in php, using Symfony's console component. want to allow the option to set a base directory other than the apps base dir (../ out of vendor folder)

ie

  • the app lives at foo/
  • package inside foo/vendor
  • default base dir is foo/
  • configuration option allows the pacakge to use foo/app as the base directory instead

I can set this as an option using Symfonys console package command --base="app", but I'm wondering if theres a way for the user to set it in a config file so they dont have to type it every time

Thanks so much for the help.

War es hilfreich?

Lösung

Composer does package management, that means it's job is to make sure the correct versions of packages are installed. That's the only thing it does, defining how packages could do something is completely the job of the package.

If you are developing a custom application, you can create your own configuration system using a json or yaml file for instance.

But if you are working with the Symfony2 framework. I suggest you to use the Symfony2 configuration system: "How to expose a Semantic Configuration for a Bundle"

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top