Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer.phar difference between | and ||

What is the difference between pipe and douoble pipe in composer.json file? For example:

"^1.0.0 || ^2.0.0"

and

'^1.0.0|^2.0.0'
like image 306
Roman678 Avatar asked Feb 01 '17 12:02

Roman678


People also ask

What is difference between composer and composer phar?

There is no difference - composer. phar is the executable and composer can be an alias or symlink for it, depending on the way you've installed composer.

What is phar in composer?

It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things. Now run php composer.phar in order to run Composer.

What is the difference between composer require and composer update?

composer update is mostly used in the 'development' phase, to upgrade our project packages. composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer.

What is difference between composer json and composer lock?

lock file is present resolves and installs all dependencies that you listed in composer. json , but Composer uses the exact versions listed in composer. lock to ensure that the package versions are consistent for everyone working on your project. As a result you will have all dependencies requested by your composer.


2 Answers

They're the same.

If you look into the VersionParser class (https://github.com/composer/semver/blob/1dd67fe56c0587d0d119947061a6bfc9863c101c/src/VersionParser.php#L237) you can see the following code:

$orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));

As we can see in the regex, they're is a ? after the second pipe, making it optional.

It seems that only the double pipe is documented though. (https://getcomposer.org/doc/articles/versions.md#range)

like image 129
Pierre-Yves Avatar answered Oct 16 '22 21:10

Pierre-Yves


I thinks it´s the old syntax of the composer OR logical operator. I found this reference: http://qpleple.com/understand-composer-versions (search for the pipe character)

In the introduction it says:

Here are some extracts from Composer's documentation reorganized to better understand how package versions and stability work

but I couldn't found any reference in current composer documentation, then I assume this is from an old version of the docs

like image 25
Gabriel Avatar answered Oct 16 '22 19:10

Gabriel