Home » Php » php – Composer package where to put client config?

php – Composer package where to put client config?

Posted by: admin February 25, 2020 Leave a comment


I have a composer package designed for use in other projects that has configurations, or rather default settings I’d like the end user to be able to adjust based on their intended use. The package itself can be configured to build things differently depending on the configurations passed to the package’s builder class. I’d like there to be default settings, possibly in a settings.yml file (the medium is not a concern, *.conf, *.json, *.php), may be this should go within the package? But then I imagine if that were the case it would be hard for the end user to maintain as it would be overwritten during composer updates? Anyone know what the norm for storing composer vendor packages configs is?

$parameters = [
    'handlers' => [
        // various depending on client use
        '//widget' => 'LivingMarkup\Component\Widgets\{name}',
        '//img' => 'LivingMarkup\Component\Img',
        '//a' => 'LivingMarkup\Component\A',
        '//var' => 'LivingMarkup\Component\Variable',
        '//condition' => 'LivingMarkup\Component\Condition',
        '//redact' => 'LivingMarkup\Component\Redact'
    'hooks' => [
        'beforeLoad' => 'Executed before onLoad',
        'onLoad' => 'Loads object data',
        'afterLoad' => 'Executed after onLoad',
        'beforeRender' => 'Executed before onLoad',
        'onRender' => 'RETURN_CALL',
        'afterRender' => 'Executed after onRender',

Thank you.

How to&Answers:

After a bit more searching I found a post that addresses this exact question.


To summarize, in case the above link stops working some day, here are some options:

  • “Bolt CMS does uses a config.yml.dist, which is included with the source code. And the end user can create a config.yml file if one doesn’t exist. The config.yml.dist file is part of the official project and acts as the example config file, and should not be modified.”
  • “Your own config.yml file can be tracked in your version control if you wish. Then you can put confidential or environment-specific information into config_local.yml and place that file’s name in .gitignore.”
  • “Symfony I use the parameters.yml and config.yml to pass parameters to the objects in DIC.”
  • “Phpunit uses the phpunit.xml.dist file to setup tests.”
  • “Apigen uses .neon or .yaml config files.”
  • “Flysystem asks for config options to be passed directly in the constructor”
  • “Cakephp has it’s own configuration settings, and plugins come with instructions on the keys to add. This asset compress package uses an ini file”
  • Opus is an option: https://github.com/imarc/opus