2017 © Pedro Peláez
 

library composer-config-manager

command line to manage composer configuration file

image

yoanm/composer-config-manager

command line to manage composer configuration file

  • Thursday, May 4, 2017
  • by yoanm
  • Repository
  • 0 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

composerConfigManager

Scrutinizer Build Status Scrutinizer Code Quality Code Coverage, (*1)

Travis Build Status PHP Versions, (*2)

Latest Stable Version, (*3)

Command to manage composer configuration file, (*4)

, (*5)

Install

composer global require yoanm/composer-config-manager

Add the following in your .bashrc file :, (*6)

export PATH=~/.composer/vendor/bin:$PATH 

, (*7)

How to

just type the following, (*8)

composercm create "vendor/package-name" path/to/repository/directory [OPTIONS]
composercm update path/to/repository/directory [OPTIONS]

In case you launch the command from the repository directory, you can simply use, (*9)

composercm create "vendor/package-name" [OPTIONS]
composercm update [OPTIONS]
  • Type composercm list to list all available command
  • Type composercm help COMMAND_NAME or composercm COMMAND_NAME -h to display help for a specific command

See below for more information regarding command line options, (*10)

  • composercm update command will take the current composer.json file and will applied given values, (*11)

    Create

  • A --template option is available, given values will be applied to the template
  • Values are appended in a default order

Update

  • A --template option is available, see below how templates are managed
  • Key order are kept from old configuration file. New one are appended in a default order

Templates

  • Multiple template could be provided. Update workflow is the following, (*12)

    • 1 - Templates between them If more than one template is given,, (*13)

      • the first first one is updated with values from the second one
      • resulting configuration is updated with third template

      ..., (*14)

      • resulting configuration is updated with X template
    • 2 - Resulting configuration with existing one
      • For update command only, in case at least a template was given
    • 3 - Resulting configuration with command line values
      • Could by skipped if only templates are used

Key order

  • By default key order as the one defined in composer documentation website
  • It's possible to use the --template option to define key order of final configuration     For instance, defined a template file name key_order.json with following content :  , (*15)

    {
    "name": null,
    "type": null,
    "license": null,
    "version": null,
    "description": null,
    "keywords": [],
    "authors": {},
    "provide": {},
    "suggest": {},
    "support": {},
    "autoload": {},
    "autoload-dev": {},
    "require": {},
    "require-dev": {},
    "scripts": {}
    }
    

      Then use the following command :, (*16)

    composercm [create|update] [ARGS] [OPTIONS] --template key_order.json
    

    Resulting file will have keys ordered like in key_order.json file. All keys could be added in key_order.json, in case no value is given for a key, key will not appear in final file., (*17)

      In case you also want to provide a template with default value, use the following:, (*18)

    composercm [create|update] [ARGS] [OPTIONS] --template key_order.json --template default_values.json [--template another.json]
    

, (*19)

Managed properties

Following properties could be defined with option from command line :, (*20)

  • Package name
  • Package type
  • License
  • Version
  • Description
  • Keywords Many allowed
  • Author Many allowed
  • Provided packages Many allowed
  • Suggested packages Many allowed
  • Support Many allowed
  • PSR-0 / PSR-4 Autoload Many allowed
  • PSR-0 / PSR-4 Autoload dev Many allowed
  • Required packages Many allowed
  • Required dev packages Many allowed
  • Scripts

All others properties could ever be defined in templates and will be managed in a default way (could produce unexpected merge for complex nested values), (*21)

, (*22)

Full composer configuration

{
  "name": "vendor/package-name",
  "type": "library",
  "license": "LICENSE_TYPE",
  "version": "X.Y.Z",
  "description": "package description",
  "keywords": ["KEYWORD1", "KEYWORD2"],
  "authors": [
    {
      "name": "name1",
      "email": "email1",
      "role": "role1"
    },
    {
      "name": "name2",
      "email": "email2",
      "role": "role2"
    }
  ],
  "provide": {
    "package1": "~x.y",
    "package2": "x.y.z",
  },
  "suggest": {
    "package1": "Description 1",
    "package2": "Description 2",
  },
  "support": {
    "type1": "url1"
  },
  "autoload": {
    "psr-0": {
      "\\RootNamespace\\SubNamespace": "path"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "\\RootNamespace\\SubNamespace\\": "path"
    }
  },
  "require": {
    "requirement1": ">=x.y"
  },
  "require-dev": {
    "requirement1": ">=x.y"
  },
  "scripts": {
    "script-1": [
      "command_1",
      "command_2"
    ],
    "script-2": [
      "command_1",
      "command_2"
    ],
  }
}

, (*23)

Contributing

See contributing note, (*24)

The Versions