PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 21, 2022

[FIXED] How does composer.json record --prefer-source

 January 21, 2022     composer-php     No comments   

Issue

One can add a package from the command line with the --prefer-source option. Surely should result in a change to composer.json? How is this shown? I can't see any difference after using --prefer-source.


Solution

There is no difference recorded in the composer.json file if you --prefer-source or --prefer-dist. The only thing is the name and version constraint for the package itself.

The difference may occur inside composer.lock and in the vendor folder itself. If packages are already installed, their state is reflected in the way they are present in the vendor folder. If they are a checked-out repository, then Composer will continue to treat them like --prefer-source, which might speed up some operations when switching to different versions. If there is no repository, Composer will continue to treat that folder as --prefer-dist.

Note that either source or dist will only work if the appropriate information has been recorded in composer.lock. Without a download location for dist recorded, installing the dependencies will result in a checkout of the repository, and vice versa. If both information is available, and one of the methods fails, the other one is tried, i.e. if the download link fails, a checkout is performed.

The --prefer-source option really only affects the download and install itself, not the way how the dependency is recorded - which makes sense, because you might like to have the source checked out when developing, but you don't want to clone entire repositories when deploying to production. With the command line flag for composer install you can change your mind anytime you install dependencies into a fresh vendor folder, and your previous choice is kept if installing into an existing vendor folder.



Answered By - Sven
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing