Composer doesn't update outdated dependencies - php

Well, after running command composer outdated I can see there's newer version of phpdocumentor/type-resolver available. Installed version is 0.2.1 and the latest one is 0.3.0. Need to say that it was indirectly installed by component I use and not by me.
Problem is when I run composer update or composer update phpdocumentor/type-resolver it says "Nothing to install or update". Why and how to fix?

probably some dependency have fixed the package release you want to install. Try so the the output of the command to check who are using and at which version the package you listed:
composer why-not phpdocumentor/type-resolver 0.3.0
NB: in the current version of the documentation of composer the command is named prohibits, so in case this doesn't work try with:
composer prohibits phpdocumentor/type-resolver 0.3.0
Hope this help

You might have version constraints blocking the upgrade in your composer.json file. This is intended to prevent adding in breaking changes. In your example, the versions are pre-release (0.*), so versioning constraints even act on the miner version.
If you are confident there are no breaking changes or you are prepared to deal with them, edit your composer.json file. Change something like:
"phpdocumentor/type-resolver": "0.2.1",
to
"phpdocumentor/type-resolver": "^0.3",
Try composer upgrade again and test it out to make sure everything is ok.

Related

PHP composer install different files version than GitHub

I tried to install this package: https://github.com/reactphp/filesystem
from composer 2.0.13 using this command:
composer require react/filesystem:^0.1.2
Which is the latest current version of this GitHub package.
But for some reason the files content that I'm getting is far different than the one on GitHub , It lacks lots of functions.
It makes me wondered if any of my other composer packages are truely updated..
As for right now I clone it manualy but what makes composer clone a diffrent files?
I tired clearing cache, re-Install, ignore platform requirements and update both composer and packages.
You required a stable version of this package, and got the v0.1.2. Composer package versions usually correspond to Git tags. If you look at the repository tags, you can see that v0.1.2 is commit 766cdef from 27 Oct 2018.
On the repository front page you see the code in its latest version (last commit of main branch), which actually is fc89dc2 committed on 8 May 2020.
The missing code you are talking about probably isn't released yet and may be unstable.
If you still want to install the latest version (there are good reasons for that), change the minimum-stability of your composer.json to dev and require the dev-master version of the package.

Laravel composer install giving error "Your lock file does not contain a compatible set of packages please run composer update"

I have been writing laravel code for quite sometime. Currently, I tried cloning a project from github and editing locally. I installed composer in my project directory but a vendor folder was not included, I tried to run composer install but I gives me this error
Your lock file does not contain a compatible set of packages. Please run composer update
How do I resolve this?
Note: I have tried running composer update on previous clones and that didn't work.
Run this command:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
Disclaimer, this solution will not fix the issue for PHP 8 projects.
In most cases this happens because of PHP 8 (In my case it was GitHub CI actions automatically started using PHP 8 even though my project is php 7.4)
If you have multiple PHP installations (E.g. 7.4 and 8 on the same server), this is how you can fix it.
Specify your php version in your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
If you have the lock file already committed, run composer update after you adding above line in to the composer.json and then commit the new lock file. (Please be aware composer update will upgrade your packages to latest versions)
I solved this problem with this command:
composer self-update --1
It probably works because at time that the project was developed, composer was on another version and when change the Major version from 1 to 2 the compatibility was broke. With this command you downgrade composer and probably going to solve this
You should try running composer update --lock that will update all packages and recreate the compose.lock file.
Either you can delete the composer.lock file and run composer install that will also recreate the .lock file.
This resolved my issue.
I had this error with Github Actions trying to deploy a Laravel app, this is probably different than the OP's case but none of the suggestions worked for me. Adding my answer here just in case there is someone else out there with a similar problem to mine.
I had to disable -q in Github Actions and see that it was complaining about extensions not being installed.
Make sure your require section of composer's php extensions matches the extensions: in your github action file for shivammathur/setup-php#v2 and it will deploy again
Recently I've just come across of this error when I tried to run my Laravel 7 project which required php v7.* with php v8. As I forgot my php version I just tried bunch of composer command, but just got error after error.
Anyway, to solve this just downgrade/upgrade php version as required. Just search how to do that in youtube.
you can see your project required php version in composer.json file (just if you wonder)
Also you can try following way (But though it didn't worked for me, seems it helped quite some people)
-- Open composer.json file and change php version to something like this: "php": "^7.3|^8.1"
-- Then run composer update
I faced this problem with my cakephp project in garuda linux (arch based)
Fix :
Install php-intl using sudo pacman -S php-intl
Enable php intl by editing php config ( in my case /etc/php/php.ini ) .
add extension=intl or uncomment the existing one
restart apache or whatever you are using
I had the same error deploying another project with composer, but the problem was a missing php extension.
I understand you solve your problem but for anyone seeing the same error message, here is a general guidance :
The error message Your lock file does not contain a compatible set of packages. Please run composer update is shown each time there is a conflict during the dependency solving step of composer install. (see the relevant part in composer source code)
It doesn't inform on the real problem though, and it could be hard to guess.
To get the exact explanation you can add --verbose option to composer install command (the option is available to any composer command (see the doc)) : composer install --verbose
It will give you the full message explaining what exactly is preventing composer install from completing (package version conflict, missing php extension, etc.), then you'll be able to fix the problem.
Hope this could help.
In my case this problem is occuring in Ubuntu 20.04 Desktop. This is due to some missing packages.
I ran the following commands to install some packages then rerun Composer install and its working properly. The commands are:
sudo apt-get install php-mbstring
sudo apt-get install php-xml
Then rerun composer install

Symfony 2.8 TinyMCE install bundle error

i am on symfony 2.8, and my php version is 5.5.9.
i'm trying to install TINYMCE bundle from composer. I used this command line:
php composer.phar require stfalcon/tinymce-bundle='1.0'
i had this message error:
i tried with v2.0 but same problem.
Have you an idea ?
Thank's a lot for your help.
It would seem that in your composer.json's config section you have platform requirements that conflict with the bundle.
https://getcomposer.org/doc/06-config.md#platform
You could try installing the requirements using the option --ignore-platform-reqs:
composer require stfalcon/tinymce-bundle --ignore-platform-reqs
composer install --ignore-platform-reqs
This will momentarily lift the specified platform requirements. Obviously if they are in place, because they are actually needed - and since they were put there deliberately, at least at some point they were - this might break things on production. So be careful and look at the above option first (updating or removing the platform requirements).
Have you tried either of these two commands:
composer.phar require stfalcon/tinymce-bundle='1.0'
composer require stfalcon/tinymce-bundle='1.0'
I'm not sure if it will make a difference, but it might.

Composer installation order

Is it possible to set the installation order?
Currently I'm using Doctrine module that requires ext-mongo to be installed, but as I'm using the newer php version (7.0) I have mongodb installed instead. There's a alcaeus/mongo-php-adapter package that resolves installation problems. But there's one problem - Composer is trying to install Doctrine modules first, so that installation fails.
Currently I have to resolve this problem manually, but I can't do it any more as I'm going to pack my environment to a Docker image to let it be automatically deployed later.
From the docs of alcaeus/mongo-php-adapter
"
$ composer require alcaeus/mongo-php-adapter
If your project already has a dependency on ext-mongo, the command above may not work. This is due to a bug in composer, see https://github.com/composer/composer/issues/5030
To fix this, you can use the --ignore-platform-reqs switch when running the above command, or when running composer update with no composer.lock file present."

how to downgrade dependency of my dependencies version [composer]

I did composer update recently. But new version of my dependencies what I got I completely don't like. I would say that I don't like dependency of my dependencies, it's more precise. Is there any way to roll back, except fetching from git history composer.lock?
There is no direct way of downgrading a dependency of a dependency; it takes some work:
Require the package in the desired version
composer require aws/aws-sdk-php=3.158.17
The dependency will be downgraded. It also gets added to composer.json which we don't want, because our application does not depend on it.
Simply removing the dependency with "composer remove" will upgrade the package to the lastest version which we don't want.
So instead, manually remove the require line from composer.json and run composer update nothing to update the hash in composer.lock.
I've had a similar problem with laravel/passport =7.5.1, that depends on league/oauth2-server ^7.0, that requires lcobucci/jwt ^3.2.2. And at the time, lcobucci/jwt was updated to latest 3.4 version. But this sudden update introduces the bug, so everyone has to downgrade it to 3.3.*.
You can override the version of nested dependency needed or apply another version number constraint by simply putting it in require section of your top-level composer.json:
"require": {
...
"lcobucci/jwt": "3.3.*"
}
Then don't forget to run composer update lcobucci/jwt, so it installs the right version of nested dependency and updates the record in composer.lock.
Today it is better to put the version to 3.4 and also install mbstring on your system with the command:
sudo apt-get install php-mbstring
If you are under ubuntu and finally do a composer update lcobucci / jwt just like you say.

Categories