:musical_note: Provides a composer plugin for normalizing composer.json.

Last update: May 28, 2022

composer-normalize

Integrate Prune Release Renew Update

Code Coverage Type Coverage

Latest Stable Version Total Downloads

Provides a composer plugin for normalizing composer.json.

Hmm, kinda cool I guess

Why

When it comes to formatting composer.json, you have the following options:

  • you can stop caring
  • you can format it manually (and request changes when contributors format it differently)
  • you can use ergebnis/composer-normalize

ergebnis/composer-normalize normalizes composer.json, so you don't have to.

đź’ˇ If you want to find out more, take a look at the examples and read this blog post.

Installation

Composer

Run

$ composer require --dev ergebnis/composer-normalize

to install ergebnis/composer-normalize as a composer plugin.

Phar

Head over to http://github.com/ergebnis/composer-normalize/releases/latest and download the latest composer-normalize.phar.

Run

$ chmod +x composer-normalize.phar

to make the downloaded composer-normalize.phar executable.

Phive

Run

$ phive install ergebnis/composer-normalize

to install ergebnis/composer-normalize with PHIVE.

Usage

Composer

Run

$ composer normalize

to normalize composer.json in the working directory.

Phar

Run

$ ./composer-normalize.phar

to normalize composer.json in the working directory.

Phive

Run

$ ./tools/composer-normalize

to normalize composer.json in the working directory.

Details

The NormalizeCommand provided by the NormalizePlugin within this package will

  • determine whether a composer.json exists
  • determine whether a composer.lock exists, and if so, whether it is up to date (unless the --no-check-lock option is used)
  • use normalizers to normalize the content of composer.json
  • format the normalized content (either as sniffed, or as specified using the --indent-size and --indent-style options)
  • write the normalized and formatted content of composer.json back to the file
  • update the hash in composer.lock if it exists and if an update is necessary

Arguments

  • file: Path to composer.json file (optional, defaults to composer.json in working directory)

Options

  • --diff: Show the results of normalizing
  • --dry-run: Show the results of normalizing, but do not modify any files
  • --indent-size: Indent size (an integer greater than 0); should be used with the --indent-style option
  • --indent-style: Indent style (one of "space", "tab"); should be used with the --indent-size option
  • --no-check-lock: Do not check if lock file is up to date
  • --no-update-lock: Do not update lock file if it exists

As an alternative to specifying the --indent-size and --indent-style options, you can also use composer extra to configure these options in composer.json:

{
  "extra": {
    "composer-normalize": {
      "indent-size": 2,
      "indent-style": "space",
    }
  }
}

đź’ˇ The configuration provided in composer extra always overrides the configuration provided via command line options.

Continuous Integration

If you want to run this in continuous integration services, use the --dry-run option.

$ composer normalize --dry-run

In case composer.json is not normalized (or composer.lock is not up-to-date), the command will fail with an exit code of 1 and show a diff.

Normalizers

The ComposerJsonNormalizer composes normalizers provided by ergebnis/json-normalizer:

as well as the following normalizers provided by this package:

BinNormalizer

If composer.json contains an array of scripts in the bin section, the BinNormalizer will sort the elements of the bin section by value in ascending order.

đź’ˇ Find out more about the bin section at https://getcomposer.org/doc/04-schema.md#bin.

ConfigHashNormalizer

If composer.json contains any configuration in the

  • config
  • extra
  • scripts-descriptions

sections, the ConfigHashNormalizer will sort the content of these sections by key in ascending order.

đź’ˇ Find out more about the config section at https://getcomposer.org/doc/06-config.md.

PackageHashNormalizer

If composer.json contains any configuration in the

  • conflict
  • provide
  • replace
  • require
  • require-dev
  • suggest

sections, the PackageHashNormalizer will sort the content of these sections.

đź’ˇ This transfers the behaviour from using the --sort-packages or sort-packages configuration flag to other sections. Find out more about the --sort-packages flag and configuration at https://getcomposer.org/doc/06-config.md#sort-packages and https://getcomposer.org/doc/03-cli.md#require.

VersionConstraintNormalizer

If composer.json contains version constraints in the

  • conflict
  • provide
  • replace
  • require
  • require-dev

sections, the VersionConstraintNormalizer will ensure that

  • all constraints are trimmed
  • and constraints are separated by a single space ( ) or a comma (,)
  • or constraints are separated by double-pipe with a single space before and after (||)
  • range constraints are separated by a single space ( )

đź’ˇ Find out more about version constraints at https://getcomposer.org/doc/articles/versions.md.

Examples

pestphp/pest

Running

$ composer normalize

against https://github.com/pestphp/pest/blob/v0.3.19/composer.json yields the following diff:

diff --git a/composer.json b/composer.json
index 1cfbf1e..204f20f 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,32 @@
         "pestphp/pest-plugin-init": "^0.3",
         "phpunit/phpunit": ">= 9.3.7 <= 9.5.0"
     },
+    "require-dev": {
+        "illuminate/console": "^7.16.1",
+        "illuminate/support": "^7.16.1",
+        "laravel/dusk": "^6.9.1",
+        "mockery/mockery": "^1.4.1",
+        "pestphp/pest-dev-tools": "dev-master"
+    },
+    "config": {
+        "preferred-install": "dist",
+        "sort-packages": true
+    },
+    "extra": {
+        "branch-alias": {
+            "dev-master": "0.3.x-dev"
+        },
+        "laravel": {
+            "providers": [
+                "Pest\\Laravel\\PestServiceProvider"
+            ]
+        },
+        "pest": {
+            "plugins": [
+                "Pest\\Plugins\\Version"
+            ]
+        }
+    },
     "autoload": {
         "psr-4": {
             "Pest\\": "src/"
@@ -42,49 +68,23 @@
             "tests/Autoload.php"
         ]
     },
-    "require-dev": {
-        "illuminate/console": "^7.16.1",
-        "illuminate/support": "^7.16.1",
-        "laravel/dusk": "^6.9.1",
-        "mockery/mockery": "^1.4.1",
-        "pestphp/pest-dev-tools": "dev-master"
-    },
     "minimum-stability": "dev",
     "prefer-stable": true,
-    "config": {
-        "sort-packages": true,
-        "preferred-install": "dist"
-    },
     "bin": [
         "bin/pest"
     ],
     "scripts": {
         "lint": "php-cs-fixer fix -v",
-        "test:lint": "php-cs-fixer fix -v --dry-run",
-        "test:types": "phpstan analyse --ansi --memory-limit=0",
-        "test:unit": "php bin/pest --colors=always --exclude-group=integration",
-        "test:integration": "php bin/pest --colors=always --group=integration",
-        "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
         "test": [
             "@test:lint",
             "@test:types",
             "@test:unit",
             "@test:integration"
-        ]
-    },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "0.3.x-dev"
-        },
-        "pest": {
-            "plugins": [
-                "Pest\\Plugins\\Version"
-            ]
-        },
-        "laravel": {
-            "providers": [
-                "Pest\\Laravel\\PestServiceProvider"
-            ]
-        }
+        ],
+        "test:integration": "php bin/pest --colors=always --group=integration",
+        "test:lint": "php-cs-fixer fix -v --dry-run",
+        "test:types": "phpstan analyse --ansi --memory-limit=0",
+        "test:unit": "php bin/pest --colors=always --exclude-group=integration",
+        "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always"
     }
 }

phpspec/phpspec

Running

$ composer normalize

against https://github.com/phpspec/phpspec/blob/7.0.1/composer.json yields the following diff:

diff --git a/composer.json b/composer.json
index 90150a37..276a2ecd 100644
--- a/composer.json
+++ b/composer.json
@@ -1,72 +1,73 @@
 {
-    "name":         "phpspec/phpspec",
-    "description":  "Specification-oriented BDD framework for PHP 7.1+",
-    "keywords":     ["BDD", "SpecBDD", "TDD", "spec", "specification", "tests", "testing"],
-    "homepage":     "http://phpspec.net/",
-    "type":         "library",
-    "license":      "MIT",
-    "authors":      [
+    "name": "phpspec/phpspec",
+    "type": "library",
+    "description": "Specification-oriented BDD framework for PHP 7.1+",
+    "keywords": [
+        "BDD",
+        "SpecBDD",
+        "TDD",
+        "spec",
+        "specification",
+        "tests",
+        "testing"
+    ],
+    "homepage": "http://phpspec.net/",
+    "license": "MIT",
+    "authors": [
         {
-            "name":      "Konstantin Kudryashov",
-            "email":     "[email protected]",
-            "homepage":  "http://everzet.com"
+            "name": "Konstantin Kudryashov",
+            "email": "[email protected]",
+            "homepage": "http://everzet.com"
         },
         {
-            "name":      "Marcello Duarte",
-            "homepage":  "http://marcelloduarte.net/"
+            "name": "Marcello Duarte",
+            "homepage": "http://marcelloduarte.net/"
         },
         {
-            "name":      "Ciaran McNulty",
-            "homepage":  "https://ciaranmcnulty.com/"
+            "name": "Ciaran McNulty",
+            "homepage": "https://ciaranmcnulty.com/"
         }
     ],
-
     "require": {
-        "php":                      "^7.3 || 8.0.*",
-        "phpspec/prophecy":         "^1.9",
-        "phpspec/php-diff":         "^1.0.0",
-        "sebastian/exporter":       "^3.0 || ^4.0",
-        "symfony/console":          "^3.4 || ^4.4 || ^5.0",
+        "php": "^7.3 || 8.0.*",
+        "ext-tokenizer": "*",
+        "doctrine/instantiator": "^1.0.5",
+        "phpspec/php-diff": "^1.0.0",
+        "phpspec/prophecy": "^1.9",
+        "sebastian/exporter": "^3.0 || ^4.0",
+        "symfony/console": "^3.4 || ^4.4 || ^5.0",
         "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.0",
-        "symfony/process":          "^3.4 || ^4.4 || ^5.0",
-        "symfony/finder":           "^3.4 || ^4.4 || ^5.0",
-        "symfony/yaml":             "^3.4 || ^4.4 || ^5.0",
-        "doctrine/instantiator":    "^1.0.5",
-        "ext-tokenizer":            "*"
+        "symfony/finder": "^3.4 || ^4.4 || ^5.0",
+        "symfony/process": "^3.4 || ^4.4 || ^5.0",
+        "symfony/yaml": "^3.4 || ^4.4 || ^5.0"
+    },
+    "conflict": {
+        "sebastian/comparator": "<1.2.4"
     },
-
     "require-dev": {
-        "behat/behat":           "^3.3",
-        "symfony/filesystem":    "^3.4 || ^4.0 || ^5.0",
-        "phpunit/phpunit":       "^8.0 || ^9.0"
+        "behat/behat": "^3.3",
+        "phpunit/phpunit": "^8.0 || ^9.0",
+        "symfony/filesystem": "^3.4 || ^4.0 || ^5.0"
     },
-
     "suggest": {
         "phpspec/nyan-formatters": "Adds Nyan formatters"
     },
-
-    "conflict": {
-        "sebastian/comparator" : "<1.2.4"
+    "extra": {
+        "branch-alias": {
+            "dev-main": "7.0.x-dev"
+        }
     },
-
     "autoload": {
         "psr-0": {
             "PhpSpec": "src/"
         }
     },
-
     "autoload-dev": {
         "psr-0": {
             "spec\\PhpSpec": "."
         }
     },
-
-    "bin": ["bin/phpspec"],
-
-    "extra": {
-        "branch-alias": {
-            "dev-main": "7.0.x-dev"
-        }
-    }
-
+    "bin": [
+        "bin/phpspec"
+    ]
 }

phpunit/phpunit

Running

$ composer normalize

against https://github.com/phpspec/phpspec/blob/7.0.1/composer.json yields the following diff:

diff --git a/composer.json b/composer.json
index fd6461fc3..23c3a3596 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
 {
     "name": "phpunit/phpunit",
-    "description": "The PHP Unit Testing framework.",
     "type": "library",
+    "description": "The PHP Unit Testing framework.",
     "keywords": [
         "phpunit",
         "xunit",
@@ -16,10 +16,6 @@
             "role": "lead"
         }
     ],
-    "support": {
-        "issues": "https://github.com/sebastianbergmann/phpunit/issues"
-    },
-    "prefer-stable": true,
     "require": {
         "php": ">=7.3",
         "ext-dom": "*",
@@ -54,20 +50,22 @@
         "ext-PDO": "*",
         "phpspec/prophecy-phpunit": "^2.0.1"
     },
+    "suggest": {
+        "ext-soap": "*",
+        "ext-xdebug": "*"
+    },
     "config": {
+        "optimize-autoloader": true,
         "platform": {
             "php": "7.3.0"
         },
-        "optimize-autoloader": true,
         "sort-packages": true
     },
-    "suggest": {
-        "ext-soap": "*",
-        "ext-xdebug": "*"
+    "extra": {
+        "branch-alias": {
+            "dev-master": "9.5-dev"
+        }
     },
-    "bin": [
-        "phpunit"
-    ],
     "autoload": {
         "classmap": [
             "src/"
@@ -86,9 +84,11 @@
             "tests/_files/NamespaceCoveredFunction.php"
         ]
     },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "9.5-dev"
-        }
+    "prefer-stable": true,
+    "bin": [
+        "phpunit"
+    ],
+    "support": {
+        "issues": "https://github.com/sebastianbergmann/phpunit/issues"
     }
 }

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using the MIT License.

Please have a look at LICENSE.md.

Credits

The algorithm for sorting packages in the PackageHashNormalizer has been adopted from Composer\Json\JsonManipulator::sortPackages() (originally licensed under MIT by Nils Adermann and Jordi Boggiano), which I initially contributed to composer/composer with composer/composer#3549 and composer/composer#3872.

Curious what I am building?

📬 Subscribe to my list, and I will occasionally send you an email to let you know what I am working on.

GitHub

https://github.com/ergebnis/composer-normalize
Comments
  • 1. Interface 'Localheinz\Json\Normalizer\NormalizerInterface' not found exception

    Steps required to reproduce the problem

    1. Go PHP 7.1
    2. composer global require localheinz/composer-normalize
    3. composer update

    Expected Result

    • Normal composer update output

    Actual Result

    • Fatal error: Interface 'Localheinz\Json\Normalizer\NormalizerInterface' not found in /Users/user/.composer/vendor/localheinz/composer-normalize/src/Normalizer/ComposerJsonNormalizer.php on line 20
    Reviewed by aviator-ua at 2018-05-21 11:50
  • 2. Plugin doesn't work when using http proxy

    Steps required to reproduce the problem

    1. use proxy for accessing Internet
    2. define env vars for using proxy https://gist.github.com/ozh/9751639
    3. create project using composer, update some vendors - composer works ok
    4. try run composer normalize

    Expected Result

    composer.json was normalized.

    Actual Result

    docker-compose exec app composer normalize -vvv
    Reading ./composer.json
    Loading config file ./composer.json
    Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
    Executing command (/srv/app): git branch --no-color --no-abbrev -v
    Reading /root/.composer/composer.json
    Loading config file /root/.composer/composer.json
    Reading /srv/app/vendor/composer/installed.json
    Reading /root/.composer/vendor/composer/installed.json
    Loading plugin PackageVersions\Installer
    Loading plugin Symfony\Flex\Flex
    Loading plugin Localheinz\Composer\Normalize\NormalizePlugin
    Loading plugin Pyrech\ComposerChangelogs\ChangelogsPlugin
    Running 1.7.2 (2018-08-16 16:57:12) with PHP 7.2.9 on Linux / 4.15.0-29-generic
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
    Reading ./composer.json
    Loading config file ./composer.json
    Executing command (/srv/app): git branch --no-color --no-abbrev -v
    Reading /root/.composer/composer.json
    Loading config file /root/.composer/composer.json
    Reading /srv/app/vendor/composer/installed.json
    Reading /root/.composer/vendor/composer/installed.json
    Loading plugin PackageVersions\Installer_composer_tmp0
    Loading plugin Symfony\Flex\Flex_composer_tmp1
    Loading plugin Localheinz\Composer\Normalize\NormalizePlugin_composer_tmp2
    Loading plugin Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp3
    Reading ./composer.lock
    Reading ./composer.lock
    Schema URI "https://getcomposer.org/schema.json" does not reference a document that could be read.
    

    see for reference how composer handles HTTP_PROXY env var https://github.com/composer/composer/blob/d5a9d86ee4e934d06073521e630556d4f337629c/src/Composer/Util/StreamContextFactory.php#L43

    Reviewed by Koc at 2018-09-14 12:28
  • 3. Installation fails in fresh project (with no other dependencies)

    Steps required to reproduce the problem

    1. Make a fresh project without any dependencies.
    2. Run composer require ergebnis/composer-normalize and wait for it to finish.
    3. See an error message.

    Expected Result

    Install without errors. Tried on 3 machines and all result in the same issue.

    Actual Result

    ❯ composer require ergebnis/composer-normalize
    Using version ^2.10 for ergebnis/composer-normalize
    ./composer.json has been created
    Running composer update ergebnis/composer-normalize
    Loading composer repositories with package information
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Root composer.json requires ergebnis/composer-normalize ^2.10 -> satisfiable by ergebnis/composer-normalize[2.10.0].
        - ergebnis/composer-normalize 2.10.0 requires ergebnis/json-printer ^3.1.1 -> found ergebnis/json-printer[dev-main] but it does not match the constraint.
    
    
    Installation failed, deleting ./composer.json.
    
    Reviewed by faustbrian at 2020-11-04 11:22
  • 4. Schema URI "schema-lax.json" could not be resolved

    Steps required to reproduce the problem

    1. composer global update
    2. composer normalize

    Expected Result

    • No error

    Actual Result

    Schema URI "file://.../vendor/ergebnis/composer-normalize/resource/schema-lax.json" could not be resolved.

    Reviewed by odan at 2020-04-30 22:11
  • 5. PHP Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found

    Steps required to reproduce the problem

    1. install globally via composer global require localheinz/composer-normalize
    2. cd to composer project directory and run composer normalize --dry-run

    Expected Result

    • a diff output of what changes would be applied

    Actual Result

    • PHP Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found
    PHP Fatal error:  Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
    Stack trace:
    #0 /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
    #1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
    #2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
    #3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #4 p in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73
    
    Fatal error: Uncaught Error: Class 'SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder' not found in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php:73
    Stack trace:
    #0 /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/NormalizePlugin.php(52): Localheinz\Composer\Normalize\Command\NormalizeCommand->__construct(Object(Composer\Factory), Object(Localheinz\Composer\Json\Normalizer\ComposerJsonNormalizer))
    #1 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(466): Localheinz\Composer\Normalize\NormalizePlugin->getCommands()
    #2 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php(156): Composer\Console\Application->getPluginCommands()
    #3 phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #4 p in /Users/brian.tully/.composer/vendor/localheinz/composer-normalize/src/Command/NormalizeCommand.php on line 73
    

    I've tried clearing composer's cache and reinstalling composer-normalize to no avail. Running latest stable composer (1.8.5)

    Reviewed by briantully at 2019-06-08 17:17
  • 6. Sort order improvement suggestion

    There are no discussions in this project, so do not judge strictly.

    The screenshot below shows two options for formatting the file: on the left is the format I am trying to adhere to, and on the right is the processed by normalize.

    image

    I prefer to keep the "name" and "description" keys together as they contain a lot of text and separating them with a short "type" string is bad, in my opinion, as it spoils the look.

    Also, I prefer to include the "config" block at the bottom of the file, as it refers to the composer rules, not the application.

    I prefer to place the "support" block above the "require" block.

    Thus, I try to divide all the keys into the following logical blocks:

    - about the project
      - general information
        - name
        - description
    
      - project type
        - type
        - license
    
      - information for search
        - keywords
        - authors
        - support  
    
    - dependencies
      - main dependencies
        - require
        - require-dev
    
      - autoload
        - autoload
        - autoload-dev
    
    - composer config
      - config
      - minimum-stability
      - prefer-stable
    
    - extended data
      - extra
    

    And this project, in this case, offers the following logical scheme:

    - about the project
      - general information
        - name
    
      - project type
        - type
    
      - general information
        - description
    
      - information for search
        - keywords
    
      - project type
        - license
    
      - information for search
        - authors
    
    - dependencies
      - main dependencies
        - require
        - require-dev
    
    - composer config
      - config
    
    - extended data
      - extra
    
    - dependencies
      - autoload
        - autoload
        - autoload-dev
    
    - composer config
      - minimum-stability
      - prefer-stable
    
      - information for search
        - support
    

    Personally, I think this formatting is illogical and makes it difficult to read the file.

    I hope this information will help you.

    Reviewed by andrey-helldar at 2021-08-20 14:02
  • 7. Restore Composer 1 support in the 2.x branch

    Hi,

    Today we bumped into an issue because Composer 2 compatibility was suddenly dropped by this plugin and our builds have started to break in those environments where still only Composer 1 is available and we have less control over the installed version.

    More information in the related Composer issue: https://github.com/composer/composer/issues/9474

    Any chance to rollback this PR from the 2.x branch and only drop support of Composer 2 in a new 3.x branch?

    Reviewed by mxr576 at 2020-11-13 16:24
  • 8. Improve "_comment" handling

    I sometimes use the common "_comment" convention convention") to compensate for JSON's lack of support for comments. Since these "comments" typically refer to the line(s) or entire file under them, I don't want composer-normalize to separate them from their context and move them to the bottom of the parent object like it currently does.

    Steps required to reproduce the problem

    1. Add a "_comment" element anywhere in a composer.json.
    2. Run composer normalize it.

    Expected Result

    • The "_comment" element retains its spacial relationship to the code (block) it refers to, or at least--more feasibly--completely ignores it.

    Actual Result

    • The "_comment" is moved to the bottom of the parent object.

    Since it would be impossible to programmatically determine whether a comment was meant to refer to the line(s) beneath it or merely appear at the top of its parent object, for instance, it seems undesirable to try. It would be very acceptable behavior, in my opinion to just ignore it.

    Reviewed by TravisCarden at 2020-05-21 18:15
  • 9. Refuses to normalize projects without name/description

    I'm starting a private project that won't be published so doesn't have a name (nor a description); here's its composer.json (minimal for now):

    {
        "type": "project",
        "license": "proprietary",
        "require": {
            "php": "^7.2"
        }
    }
    

    It is valid for non-public use:

    $ composer validate --no-check-publish
    ./composer.json is valid for simple usage with composer but has
    strict errors that make it unable to be published as a package:
    See https://getcomposer.org/doc/04-schema.md for details on the schema
    name : The property name is required
    description : The property description is required
    $ echo $?
    0
    

    but impossible to normalize as-is:

    $ composer normalize
    Original JSON is not valid according to schema "file:///home/gx/.composer/vendor/ergebnis/composer-normalize/src/../resource/schema.json".
    ./composer.json is valid for simple usage with composer but has
    strict errors that make it unable to be published as a package:
    See https://getcomposer.org/doc/04-schema.md for details on the schema
    $ echo $?
    0
    

    (note: the message doesn't say what the strict errors are, and the command doesn't return an error code despite not being successful).

    To work around, I have to run the sequence:

    1. composer config name a/a (dummy but valid name)
    2. composer config description ""
    3. composer update --lock (if I have a composer.lock)
    4. composer normalize
    5. composer config --unset name
    6. composer config --unset description
    7. composer update --lock (if I have a composer.lock)

    Would it be feasible to mimic --no-check-publish (possibly opt-in)?

    Maybe related to #297

    Reviewed by guilliamxavier at 2020-02-11 16:28
  • 10. Work when no internet available

    Steps required to reproduce the problem

    1. Turn off internet for the device this package is ran on
    2. run composer normalize

    Expected Result

    • Works when no internet connection

    Actual Result

    • Shows the following error message Schema URI "https://getcomposer.org/schema.json" does not reference a document that could be read.
    Reviewed by WyriHaximus at 2019-06-16 15:04
  • 11. Add phive support

    would it make sense to support phive? https://github.com/phar-io/phive

    It seems this might be useful for some cases https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4536#issuecomment-526862908

    Reviewed by staabm at 2019-09-15 06:09
  • 12. composer(deps): bump ergebnis/json-normalizer from 2.1.0 to 2.2.0

    Bumps ergebnis/json-normalizer from 2.1.0 to 2.2.0.

    Release notes

    Sourced from ergebnis/json-normalizer's releases.

    2.2.0

    What's Changed

    Full Changelog: https://github.com/ergebnis/json-normalizer/compare/2.1.0...2.2.0

    Changelog

    Sourced from ergebnis/json-normalizer's changelog.

    [2.2.0][2.2.0]

    For a full diff see [2.1.0...2.2.0][2.1.0...2.2.0].

    Changed

    Commits
    • b4c8de9 Merge pull request #644 from ergebnis/fix/changelog
    • efd19cd Merge pull request #643 from ergebnis/feature/release
    • faecede Fix: Update CHANGELOG.md
    • 4b9c15b Merge pull request #642 from ergebnis/dependabot/composer/phpunit/phpunit-9.5.12
    • ae6a750 Enhancement: Automatically generate release body
    • 6af67ad composer(deps-dev): bump phpunit/phpunit from 9.5.11 to 9.5.12
    • b56423a Merge pull request #641 from ergebnis/feature/items
    • 7115bfa Enhancement: Normalize array values without schema definition
    • a34c4d7 Merge pull request #640 from ergebnis/feature/fixture
    • 3e5c997 Enhancement: Adjust fixtures
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Reviewed by dependabot[bot] at 2022-01-22 12:31
  • 13. `config.allow-plugins` should be required sorted

    Steps required to reproduce the problem

    {
        "config": {
            "allow-plugins": {
                "ergebnis/composer-normalize": true,
                "composer/package-versions-deprecated": true,
                "phpstan/extension-installer": true
            },
            "sort-packages": true
        }
    }
    

    Expected Result

    {
        "config": {
            "allow-plugins": {
                "composer/package-versions-deprecated": true,
                "ergebnis/composer-normalize": true,
                "phpstan/extension-installer": true
            },
            "sort-packages": true
        }
    }
    

    Actual Result

    not sorted

    Reviewed by mvorisek at 2022-01-17 12:47
  • 14. Normalizing composer.json in other directory inconsistency

    Steps required to reproduce the problem

    1. Having Composer 2.2 with the new allow-plugins feature
    2. First composer.json, in the root, perfectly fine:
    {
        "require": {
            "ergebnis/composer-normalize": "^2.23.0",
            "phpstan/extension-installer": "^1.1.0"
        },
        "config": {
            "allow-plugins": {
                "ergebnis/composer-normalize": true,
                "phpstan/extension-installer": true
            }
        }
    }
    
    1. Second composer.json, in subdirectory foo with a content (clearly, not normalized):
    {
        "require": {
            "psr/log" : "*",
    
            "psr/container" : "*"
        }
    }
    
    1. We run in the root composer normalize foo/composer.json

    Expected Result

    • composer.json in foo is normalized, with no questions asked

    Actual Result

    Running ergebnis/composer-normalize by Andreas Möller and contributors.
    
    ergebnis/composer-normalize contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
    Do you trust "ergebnis/composer-normalize" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] n
    phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
    Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] n
    Successfully normalized subdirectory/composer.json.
    

    Composer asks for plugins to be allowed (phpstan/extension-installer is only to show that it asks for all, not only about the currently used plugin), having using plugin denied it still normalizes composer.json.

    I'd expect normalizing composer.json without any interaction, I'd understood not normalizing it after not allowing the plugins, but this behaviour is super weird.

    Reviewed by kubawerlos at 2022-01-10 21:47
  • 15. Pass composer parameters to update subcommand

    Motivation

    ANSI or no-ANSI output is relatively trivial, but I would expect composer --foo normalize to pass --foo on to any Composer subcommands. Currently I believe it does not, and propose that we change this.

    There may be Other Considerations, I'm not strongly wedded to this change :)

    We might want to include or exclude specific composer switches to retain existing behaviour (eg --no-update-lock behaviour should not change?).

    Steps required to reproduce the problem

    1. Run composer --no-ansi normalize, eg in a CI process
    2. See ANSI output
    cd "./build/ci-basic"; composer normalize
    Running ergebnis/composer-normalize by Andreas Möller and contributors.
    Successfully normalized ./composer.json.
    Updating lock file.
    Loading composer repositories with package information
    Updating dependencies
    Nothing to modify in lock file
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 2 installs, 0 updates, 0 removals
        0 [>---------------------------]
        0 [>---------------------------]
        0 [>---------------------------]
      - Installing drupal/core (9.1.8): Extracting archive
      - Installing drupal/raven (3.2.1): Extracting archive
     0/2 [>---------------------------]   0%
     1/2 [==============>-------------]  50%
     2/2 [============================] 100%Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
    Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
    91 packages you are using are looking for funding.
    Use the `composer fund` command to find out more!
    

    Expected Result

    • Don't show ANSI output, since the parent composer command did not

    Actual Result

        0 [>---------------------------]
        0 [>---------------------------]
        0 [>---------------------------]
      - Installing drupal/core (9.1.8): Extracting archive
      - Installing drupal/raven (3.2.1): Extracting archive
     0/2 [>---------------------------]   0%
     1/2 [==============>-------------]  50%
     2/2 [============================] 100%
    
    Reviewed by xurizaemon at 2021-05-17 01:22
  • 16. Make "paths that should not be sorted" configurable

    Some elements of composer.json are highly sensitive to order, such as extra.patches with https://github.com/cweagans/composer-patches, which applies patches in the order specified and can therefore fail if it changes. See another example #699. I need a way to exclude arbitrary paths from sorting. I see that the current exclusions are hardcoded in \Ergebnis\Json\Normalizer\Vendor\Composer\ConfigHashNormalizer::PROPERTY_PATHS_THAT_SHOULD_NOT_BE_SORTED. I would like this value to be configurable like the other options. I could take a stab at a PR. Alternatively, a few specific additions to the current hardcoded list would temporarily unblock my customers. I would gladly send a PR for that, too.

    Reviewed by TravisCarden at 2021-03-05 15:05
Simple composer script to manage phar files using project composer.json.
Simple composer script to manage phar files using project composer.json.

tooly-composer-script With tooly composer-script you can version needed PHAR files in your project's composer.json without adding them directly to a V

Aug 3, 2021
Simple static Composer repository generator - For a full private Composer repo use Private Packagist

Satis Simple static Composer repository generator. Run from source Satis requires a recent PHP version, it does not run with unsupported PHP versions.

May 25, 2022
composer parallel install plugin
composer parallel install plugin

prestissimo (composer plugin) This is a composer 1.x plugin that downloads packages in parallel to speed up the installation process. Announcement: Co

May 20, 2022
A no-frills PsySH-Composer plugin
A no-frills PsySH-Composer plugin

uma/composer-psysh A no-frills PsySH-Composer plugin. In a nutshell, it provides a composer psy subcommand that spawns a Psy Shell with autoload integ

May 23, 2022
This library provides a way of avoiding usage of constructors when instantiating PHP classes.

Instantiator This library provides a way of avoiding usage of constructors when instantiating PHP classes. Installation The suggested installation met

May 21, 2022
Check your Composer dependencies at runtime.

Composition Composition provides a lightweight and generic API, that you can use to check your environment at runtime, instead of manually go checking

May 4, 2021
Patch other composer packages on install or update

patch-installer Patch other composer packages on install or update. experimental feature Usage For a patch type change the install path to vendor dire

Apr 11, 2021
Easily parse your project's Composer configuration, and those of its dependencies, at runtime

Composed This library provides a set of utility functions designed to help you parse your project's Composer configuration, and those of its dependenc

Apr 11, 2021
Satis-go is a web server for hosting and managing your Satis Repository for Composer Packages

Satis-go download latest Satis-go is a web server for hosting and managing your Satis Repository for Composer Packages Some Highlights: Satis-go provi

Dec 14, 2021
Json-normalizer: Provides generic and vendor-specific normalizers for normalizing JSON documents

json-normalizer Provides generic and vendor-specific normalizers for normalizing JSON documents. Installation Run $ composer require ergebnis/json-nor

Jan 16, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Apr 15, 2022
A composer plugin, to install differenty types of composer packages in custom directories outside the default composer default installation path which is in the vendor folder.

composer-custom-directory-installer A composer plugin, to install differenty types of composer packages in custom directories outside the default comp

Apr 22, 2022
Merge one or more additional composer.json files at Composer runtime

Composer Merge Plugin Merge multiple composer.json files at Composer runtime. Composer Merge Plugin is intended to allow easier dependency management

May 16, 2022
Simple composer script to manage phar files using project composer.json.
Simple composer script to manage phar files using project composer.json.

tooly-composer-script With tooly composer-script you can version needed PHAR files in your project's composer.json without adding them directly to a V

Aug 3, 2021
Tool to convert from composer.yml to composer.json.

composer-yaml This project allows you to convert a composer.yml file into composer.json format. It will use those exact filenames of your current work

Nov 19, 2021
Dependency graph visualization for composer.json (PHP + Composer)
Dependency graph visualization for composer.json (PHP + Composer)

clue/graph-composer Graph visualization for your project's composer.json and its dependencies: Table of contents Usage graph-composer show graph-compo

May 18, 2022
Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

Oct 3, 2020
A simple library to work with JSON Web Token and JSON Web Signature

JWT A simple library to work with JSON Web Token and JSON Web Signature based on the RFC 7519. Installation Package is available on Packagist, you can

May 19, 2022
Allows generate class files parse from json and map json to php object, including multi-level and complex objects;

nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You

Oct 29, 2021
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.

Imposter Plugin Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins. Built with ♥ by Typ

May 16, 2022