Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

unglued's avatar

Find newer versions in composer

Hi!

For example I have composer.json in my project:

{
    "require": {
        "vendor/lib": "^1.2.3"
    }
}

How to find out is the any new versions greater 2.0? Assume that I have a lot of dependencies, so no manual checks.

Thanks!

0 likes
7 replies
davorminchorov's avatar

if you use "", it will download the latest stable version but it's not recommended because the newest version might have breaking changes and your app might work as expected. A good practice is to use something like "1.2." so it picks up the latest minor updates and bugfixes.

xingfucoder's avatar

Hi, If you want to see the latest version of one package you could use the next cli composer command:

composer show packageName

For laravel/laravel you may use:

composer show laravel/laravel

The result will be:

$ composer show laravel/laravel
name     : laravel/laravel
descrip. : The Laravel Framework.
keywords : framework, laravel
versions : dev-master, v5.0.22, v5.0.16, v5.0.1, v5.0.0, v4.2.11, v4.2.0, v4.1.2
type     : project
license  : MIT
source   : [git] https://github.com/laravel/laravel.git 50cf908cba46a443956f1787
dist     : [zip] https://api.github.com/repos/laravel/laravel/zipball/50cf908cba
names    : laravel/laravel

autoload
classmap
database
psr-4
App\ => app/

requires
laravel/framework 5.0.*

requires (dev)
phpunit/phpunit ~4.0
phpspec/phpspec ~2.1

Hope it helps you.

2 likes
bobbybouwmann's avatar

There is no way to do that with composer as far as I know.. You probably need to write your own script for that and check if there is a newer version or not based on your current composer.json file

gregrobson's avatar

Quite simple:

composer update --dry-run

This will do exactly what it would do when you run composer update normally: check for versions that match the semver criteria and will tell you the newest version. Only with --dry-run it won't download or change your files.

I've just run it now as an example:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating symfony/translation (v2.5.10) to symfony/translation (v2.5.11)

  - Updating symfony/security-core (v2.5.10) to symfony/security-core (v2.5.11)

  - Updating symfony/routing (v2.5.10) to symfony/routing (v2.5.11)

  - Updating symfony/process (v2.5.10) to symfony/process (v2.5.11)

  - Updating symfony/http-foundation (v2.5.10) to symfony/http-foundation (v2.5.11)

  - Updating symfony/event-dispatcher (v2.6.4) to symfony/event-dispatcher (v2.6.6)

  - Updating symfony/debug (v2.5.10) to symfony/debug (v2.5.11)

  - Updating symfony/http-kernel (v2.5.10) to symfony/http-kernel (v2.5.11)

  - Updating symfony/finder (v2.5.10) to symfony/finder (v2.5.11)

  - Updating symfony/dom-crawler (v2.5.10) to symfony/dom-crawler (v2.5.11)

  - Updating symfony/css-selector (v2.5.10) to symfony/css-selector (v2.5.11)

  - Updating symfony/console (v2.5.10) to symfony/console (v2.5.11)

  - Updating symfony/browser-kit (v2.5.10) to symfony/browser-kit (v2.5.11)

  - Updating swiftmailer/swiftmailer (v5.3.1) to swiftmailer/swiftmailer (v5.4.0)

  - Updating phpseclib/phpseclib (0.3.9) to phpseclib/phpseclib (0.3.10)

  - Updating patchwork/utf8 (v1.1.28) to patchwork/utf8 (v1.2.2)

  - Updating nesbot/carbon (1.13.0) to nesbot/carbon (1.17.0)

  - Updating monolog/monolog (1.12.0) to monolog/monolog (1.13.1)

  - Updating filp/whoops (1.1.3) to filp/whoops (1.1.5)

  - Updating symfony/filesystem (v2.6.4) to symfony/filesystem (v2.6.6)

  - Updating laravel/framework (v4.2.16) to laravel/framework (v4.2.17)

  - Installing hamcrest/hamcrest-php (v1.2.1)

  - Updating mockery/mockery (0.9.3) to mockery/mockery (0.9.4)

  - Updating bugsnag/bugsnag (v2.5.1) to bugsnag/bugsnag (v2.5.4)

  - Updating guzzlehttp/ringphp (1.0.5) to guzzlehttp/ringphp (1.0.7)

https://getcomposer.org/doc/03-cli.md#update

1 like

Please or to participate in this conversation.