How can I recreate composer.json from the content of the vendor directory? -
i have project using composer.
however, have lost composer.json.
is there way recreate composer.json content of vendor directory?
identifying installed dependencies can achieved inspecting
vendor └── composer └── installed.json however, faced following problems:
direct , indirect dependencies
installed.json lists all installed dependencies, is, both
- direct and
- indirect
dependencies.
direct dependencies dependencies explicitly listed in require , require-dev sections.
indirect dependencies dependencies of direct dependencies.
that is, while programmatically parse installed.json , collect dependencies listed therein, need decide whether these direct or indirect dependencies, or in other words, whether want explicitly require these dependencies in composer.json.
production , development dependencies
installed.json lists all installed dependencies, is, depending on whether ran
$ composer install or
$composer install --no-dev before lost composer.json, installed.json contain direct , indirect dependencies listed in
require,require-devorrequire
sections, respectively.
that is, need decide whether these dependencies should listed in the
requireorrequire-dev
sections.
see
- https://getcomposer.org/doc/04-schema.md#require
- https://getcomposer.org/doc/04-schema.md#require-dev
- https://getcomposer.org/doc/03-cli.md#install
- using "require-dev" install packages in composer
to find out more purpose , differences between these sections.
version constraints
installed.json lists all installed dependencies exact versions installed.
however, composer.json lost in likelihood did not list dependencies exact versions, using 1 of many possibilities specifying version constraints.
that is, need decide whether want use exact versions, or relax constraints, example, using
- the
~operator - the
^operator - etc.
see
to find out more version constraints.
Comments
Post a Comment