Composer: How to generate composer.json from composer.lock file ?

Created on 14 Nov 2012  ·  3Comments  ·  Source: composer/composer

due to some reasons, one of my team mates has lost the composer.json file ( not commited to git) but locally all vendors are installed, and composer.lock file has all the vendors we need.

Is there any way to generate composer.json file using .lock file ?

Most helpful comment

well, adding this info in the composer.lock just to be able to reconstruct the composer.json file looks weird to me. It would make the lock file more complex to solve a case which does not make much sense (the composer.json is necessary)

All 3 comments

Not automatically no, that would be kind of impossible. You can open the composer.lock (it is just a json file) and copy every package name and version into your require, but that won't be the same as what you had since some of those installed packages are probably just installed because they were dependencies of your requirements, and not requirements themselves.

I also found in some project a composer.lock file without composer.json commited (:(), for such cases, it would be helpful to know which packages in composer.lock are from "require" and which are dependencies. I know that in a perfect world it wouldn't happen, but it happens apparently ;)

well, adding this info in the composer.lock just to be able to reconstruct the composer.json file looks weird to me. It would make the lock file more complex to solve a case which does not make much sense (the composer.json is necessary)

Was this page helpful?
0 / 5 - 0 ratings