Removing a package from composer's lockfile before install - composer-php

Is it possible to remove a package and it's dependencies from composer's lockfile before install?
Things I've tried that don't work:
composer remove package --no-update # Only updates composer.json
composer remove package # Removes only this package, installs all its dependancies

Related

Composer not installing dependencies

I installed the package mageplaza/module-smtp. It has the package mageplaza/module-core as requirement. (composer.json)
As I install the package with: composer require mageplaza/module-smtp it just installed that package and ignores the mageplaza/module-core dependency.
So I had to install it manually with: composer require mageplaza/module-core
Why do I need to install dependencies manually?

Cannot remove package phpoffice/phpword. (laravel 5.2)

I've been working on a Laravel project. While I'm trying to install some package. I got warned
Package phpoffice/phpexcel is abandoned, you should avoid using it.
Use phpoffice/phpspreadsheet instead.
Therefore, I executed the command
composer remove phpoffice/phpexcel
The phpoffice/phpexcel has been remove from composer.json successfully.
Then install the package,
composer require phpoffice/phpspreadsheet
I still got warned by the same warning,
Package phpoffice/phpexcel is abandoned, you should avoid using it.
Use phpoffice/phpspreadsheet instead.
I always got warned by this sentence from every composer command even the phpoffice/phpexcel has been removed from composer.json.
Pls help I really have no idea to remove this warning.
Maybe the package phpoffice/phpexcel is used by another package in your composer.json. To see if that's the case you can use the following command to find out which other packages may need phpoffice/phpexcel:
composer why phpoffice/phpexcel
Does that give you a list of packages or an error?
To avoid this error you can run the following commands --
composer remove phpoffice/phpexcel
Then -
composer require phpoffice/phpspreadsheet
Then -
composer dump-autoload
composer update

How to find and treat the cause of an outdated composer package that is not in my composer.json?

I ran composer outdated command:
$ composer outdated
phpdocumentor/type-resolver 0.4.0 0.7.1
but looking inside composer.json, I see no such package. In my case there is no type-resolver.
How do I find an outdated package that is missing in composer.json belongs to and how do I update it?
Composer install not only packages that are listed directly in composer.json but also packages that are dependencies of packages that are listed in composer.json. Assuming you have in composer package vendor/A and this package requires vendor/B you will have installed both A and B packages.
So in your case you can run:
composer update phpdocumentor/type-resolver
to try to update this package.
Of course it does not mean it will be possible to update this way. It's possible that you might need to run:
composer update
but this will update all packages (and depends on scenario this is what you can accept or maybe you don't want to update all packages).
It's also possible that it won't be possible to update this package because other package that is used has phpdocumentor/type-resolver dependency set to for example 0.4.* so 0.7 version is not compatible with this package and version 0.7 won't be installed

laravel ckeditor installation

I have install Laravel previously and it works perfectly but now when I fire command composer require unisharp/laravel-ckeditor it installs "unisharp/laravel-filemanager": "~1.8".
I have also try to install it using this link but its not worked..
I guess author have changes the package..
Anyone have any idea about it?
use
composer require ckeditor/ckeditor
result
akash#localhost /var/www/html/lara57 $ composer require ckeditor/ckeditor
Using version ^4.11 for ckeditor/ckeditor
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing ckeditor/ckeditor (4.11.3): Downloading (100%)
Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.
Writing lock file

Removing a package from composer with --no-update

I'm trying to remove a package from my application and I've run composer remove --no-update package/name, now all this does is remove the entry in composer.json but when I run composer show -i, I see the package is still installed, is there anyway to completely remove a package without running update?
I think this is exactly what the --no-update option is intended to do.
composer remove package/name should remove package/name from your project without updating other packages than package/name.
It's the same if you remove the entry from your composer.json and then run composer update package/name. It will update this specific package but no others!
If you activate the --no-update option it omits the update, so it only removes the entry.
I think what the --no-update option is intended to do is, this will avoid composer update.
for eg composer require "magento/magento-cloud-metapackage":">=2.3.3 <2.3.4" --no-update only update composer.json file not composer.lock file
while composer require "magento/magento-cloud-metapackage":">=2.3.3 <2.3.4"
updates both composer.json and composer.lock file

Resources