Composer list packages with installed version and latest version - composer-php

As in the title, is there any command that can list installed packages and the latest version of those packages together?
edit:
php composer.phar show
this show all available packages and also installed packages with installed version only
php composer.phar show [package]
this can get both installed version and latest version, but it is inconvenience if many packages are installed

Since Composer v1.1 (May 2016) you can run
composer outdated

Accordng to the docs https://getcomposer.org/doc/03-cli.md#show
composer show -l
or
composer show --latest
will "List all installed packages including their latest version"
Here are a few lines of my output:
beberlei/assert v2.5 v2.7.8 Thin assertion library for...
behat/transliterator v1.1.0 v1.2.0 String transliterator
clue/stream-filter v1.3.0 v1.4.0 A simple and modern approa...
fgrosse/phpasn1 1.3.2 1.3.2 A PHP Framework that allow...
This worked on composer 1.2 and 1.5.2

As the current version of composer -i option which tells composer to show only the installed version is deprecated.
So if you want to show only the installed version of a package, the syntax is:
composer show "package-name"
If you need to pull all available versions of the package, use --all option like this:
composer show "phpunit/phpunit" --all

I think
php composer show -i
is what you're looking for.

--outdated option
Perhaps, you are looking for --outdated option.
It will make output like this:
zendframework/zend-db 2.9.2 2.9.3 Database abstraction layer, SQL...
2.9.2 2.9.3 - installed and new available version (according to instructions in composer files).
--all option
I guess it --all should work for you within one package.
It will show your current version with the asterisk. It will look like this:
dev-master, v0.1.2-alpha.0, * v0.1.1-alpha.0, v0.1.0-alpha.1, v0.1.0-alpha.0, dev-develop
So, I have installed v0.1.1-alpha.0.
--available option
Also, there is --available option to new version.
--available (-a): List available packages only.
https://getcomposer.org/doc/03-cli.md#show
Example:
composer show --available monolog/monolog 1.0.2
In this case it will make request to available composer repositories, packagist.org or your custom ones.
P.S. My GIT version: 2.14.1

use this:
composer update --dry-run
it gives both your current versions and the latest versions of your bundles

To just show top-level packages (listed in composer.json), I use:
composer show -t | grep -v "[|\`]--" | grep -v "[└├]"

Related

Installing Prestashop developer version

I wonder if anyone has experiencing installing Prestashop 1.7 dev version on Windows 10? I cloned the developer vbersion of Prestashop from the official git repo and initiated the install. The install asks me to run the command "php composer.phar install" so I did and get the following error when I do:
Problem 1
- composer/installers is locked to version v1.7.0 and an update of this package was not requested.
- composer/installers v1.7.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint.
Use the option --with-all-dependencies to allow updates and removals for packages currently locked to specific versions.
You are using a snapshot build of Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report an issue to them to ask them to support Composer 2. To work around this you can run Composer with --ignore-platform-reqs, but this will also ignore your PHP version and may result in bigger problems down the line.
I am running the latest version of composer on Windows 10 and am at a complete loss on how to proceed any further therefore any help would be appreciated.
According to the Prestashop team their development build is not yet compatible with Composer 1.10.5 hence the errors I encountered.
Thanks.

Unable to download any pdf packages via composer for larvel 5.5

i am using laravel 5.5 with php 7.0 version, I want to generate a pdf, i tried to install many pdf packages, but unable to install because of php 7.0 version, it requires min 7.1 to install any packages, i tried to find packages for 7.0 verision, but failed.
can anyone help me how to install package for php 7.0 veriosn
Below is the error, that i am getting,
Your requirements could not be resolved to an installable set of packages.
Problem 1 - nwidart/laravel-modules 4.1.0 requires php >=7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
There are only 2 solutions out of this, You either upgrade your PHP version to 7.1 or downgrade your package versions which uses PHP7.0
If you tell me what packages are you using,I could help you out find the packages. Let me know what your use case is exactly, or why your cant upgrade to PHP7.1
Also it is important to note that PHP7.0 includes security vulnerabilities fixed in PHP7.1, So consider upgrading your framework to at-least Laravel 5.8
Edit:
here is a package for pdp utilities in laravel 5.5 -> https://github.com/niklasravnsborg/laravel-pdf
For laravel5.5 you will have to manually link the packages as auto discovery will not work.
Edit 2:
here is the problem, When you use composer require barryvdh/laravel-dompdf the composer installs the latest package which is 0.8.4 (compatible with PHP7.1 and higher), What you need to do instead is add the package manually to the composer file and then bind the version 0.8.3 like this under the require object -> "barryvdh/laravel-dompdf": "0.8.3" and then run composer update/install in the terminal

How to fix composer problems while trying to configure magento2

I am trying to install/configure magento2. I cloned it from GitHub with:
cd /var/www/html
git clone https://github.com/magento/magento2.git
After that I am trying to install Composer:
cd /var/www/html/magento2/
composer install -v
And I am getting this warning.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
I tried to install phpunit but it not helped. Any idea?
There is not much what you can do. You get this warning because Magento uses PHPUnit 6 as dev dependency. PHP 6 EOLed in February (see supported versions summary) and uses deprecated package phpunit/phpunit-mock-objects as one of its dependencies. The right way to fix this is to upgrade PHPUnit to 7.x or 8.x line, but this rather a job for Magento devs.
As a end user who just want to use Magento, you can safely ignore this warning - it is only a warning to bring your attention on fact, that you're using unmaintained package. This is not a big issues, since this is only a dev dependency, and you're probably not a Magento developer. You will not get this warning if you use --no-dev switch (which you should use for production installation anyway):
composer install --no-dev

Composer cant install because plugin API does not match composer installation

Im newbie . Help me.
how could this happen ?
here I will install laravel
The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("1.0.0 the "--no-plugins" option. The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("1.0.0 the "--no-plugins" option.
I try to back version with
composer self-update --rollback
and composer ask to update again.
How to update composer with pugins API??
Looks like composer broke api on update and now it cannot run. Try removing global composer vendor dir, which is
/root/.composer/vendor
in your case and run the update command again.

Composer.json getting latest package version and

For each new project, I want to:
Get the latest versions of all packages inside composer.json
Once I have them I no longer want to get the latest - just the version of the first run.
I know I could manually specify latest versions from packagist.org, but Ideally I'd like this automated.
I hope this makes sense.
Thanks
the latest package:
"require": {
"namespace/libname": "#dev"
}
after install of this package, composer will dump all info (and version) to composer.lock. do not remove this file and do not use composer update.
always use composer install because this will force composer to look into composer.lock file for package version
Running composer require vendor/package will consult packagist.org for the most current released version and add both the latest release and the version requirement to get this release and compatible updates later.
This will install only stable versions.
After the initial install, you have two options:
composer install will again install the previously found packages.
composer update will look for updated packages that match the version requirement.
Never run update unattended. A developer should run this consciously and then run the test suite to determine if everything still works (or the continuous integration job does it if available). Especially only run install when deploying to production.

Resources