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

Thursday, May 12, 2022

[FIXED] What does the tilde (~) mean in my composer.json file?

 May 12, 2022     composer-php, symfony, syntax     No comments   

Issue

I have this line in my composer.json file:

"require": {
    ...
    "friendsofsymfony/user-bundle": "~2.0@dev",
    ...
},

What does the tilde ~ in ~2.0@dev exactly mean? Is that a placeholder and shall always fetch the subversions like 1.2.0, 2.2.0, 3.2.0 and so on? Doesn't make sense (and would be done by the * wildcard).

The composer.json documentation doesn't tell anything about the tilde.

I am asking because I just read about a security issue in the Symfony blog and they recommend to upgrade to version 1.3.3. But figuring out the FOSUserBundle's version isn't that easy (I couldn't find a file that contains the version).


Solution

Tilde means next significant release. In your case, it is equivalent to >= 2.0, < 3.0.

The full explanation is at Tilde Version Range docs page:

The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.

Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.

Seldeak's below comment is a simple sum up explanation of the Composer documentation.



Answered By - AlterPHP
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • 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