Composer uses old package version - php

I have a custom package injected into my project via composer.json, this package is currently on version 2.0.1
I changed something in the source code of the package and set the version in the package.json to 2.0.2 pushed it to git and tried to update my composer but every time I get
- Installing myproject/laravel-jssettings (v2.0.1): Cloning 9663e29ee0 from cache
even tho I cleared the composer cache and deleted the composer.lock file
The line in my composer.json file is
"myproject/laravel-jssettings": "~2.0",
I tried to set it to
"myproject/laravel-jssettings": "2.0.2",
but then i get an error message which says
Problem 1
- The requested package myproject/laravel-jssettings 2.0.2 exists as myproject/laravel-jssettings[v2.0.0, v2.0.1] but these are rejected by your constraint.
what do i miss here, where do i have to clear the cache or change to a new version so that the composer gets the new 2.0.2 version. thx in advance

You need to craete a tag for your custom repository. After that tag will be pushed to repositroy composer will get lates updates.
git tag 2.0.2
git push origin --tags
and after that try to composer update on your project. Composer documentation

Related

Failed while installing a package using composer

iam tryin to use a cart package by using this command
composer require jason-napolitano/codeigniter4-cart-module
and it's failed. this is what it said
Using version dev-master for jason-napolitano/codeigniter4-cart-module
./composer.json has been updated
Running composer update jason-napolitano/codeigniter4-cart-module
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires jason-napolitano/codeigniter4-cart-module dev-master -> satisfiable by jason-napolitano/codeigniter4-cart-module[dev-master].
- jason-napolitano/codeigniter4-cart-module dev-master requires codeigniter4/framework ^4.0.3 -> satisfiable by codeigniter4/framework[v4.0.3, ..., v4.1.1] from composer repo (https://repo.packagist.org) but codeigniter4/framework[1.0.0+no-version-set] from root package repo has higher repository priority. The
packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
is it because my minimum-stability in composer.json is set to "stable"?
I presume you created your project by using composer create-project codeigniter4/framework. This effectively created a clean project for you without the .git folder, thus removing any metadata on what version of codeigniter4/framework package you installed. This is indicative by 1.0.0+no-version-set part of the error message.
The jason-napolitano/codeigniter4-cart-module package requires ^4.0.3 version of codeigniter4/framework, but since you have no version metadata in your project, install fails. This can be resolved by setting the version from which you bootstrapped your project manually in your root composer.json:
{
"name": "codeigniter4/framework",
"version": "4.0.3",
...
}
However, this is just a guess, since I have no insight into your main composer.json.
Your PHP is missing intl extension. It is useful for formatting currency, number and date/time as well as UCA-conformant collations, for message formatting and normalizing text..etc.
Check out Codeignitor 4 [Documentation][1]:
Follow the steps to install it in XAMPP -
Open [xampp_folder_path]/php/php.ini to edit.
Search for ;extension=intl and remove the ;.
Save the php.ini file and restart Apache.

Problem with TravisCI version matrix after updating to composer 2.0

After updating to Composer 2.0 I got into problems on doing my Travis.
I have a TYPO3 Extension, that I want to test with multiple TYPO3 Versions. Till yesterday I could do this with composer require nimut/typo3-complete:$TYPO3_VERSION (coming from the version Matrix).
After the update I got following error/information.
Cannot update only a partial set of packages without a lock file present.
Installation failed, reverting ./composer.json to its original content.
As I have no composer.lock in my repository, I tested my pipeline with a composer install first, and then did the update. This is all fine until I go to the next version as the dependencies are different, and the composer.lock from the composer install cannot update the additional dependencies.
I have tried it with composer require --dev nimut/typo3-complete:^10.4 --with-all-dependencies the response from composer:
Problem 1
- typo3/testing-framework is locked to version 4.15.2 and an update of this package was not requested.
- typo3/testing-framework 4.15.2 requires typo3/cms-backend ^9.3 -> found typo3/cms-backend[v9.3.0, ..., 9.5.x-dev] but it conflicts with another require.
Problem 2
- symfony/http-client v5.1.7 requires symfony/http-client-contracts ^2.2 -> found symfony/http-client-contracts[dev-main, dev-master, v2.2.0, v2.3.1, 2.3.x-dev (alias of dev-master)] but it conflicts with another require.
- nunomaduro/phpinsights v1.14.0 requires sensiolabs/security-checker ^6.0 -> satisfiable by sensiolabs/security-checker[v6.0.3].
- sensiolabs/security-checker v6.0.3 requires symfony/http-client ^4.3|^5.0 -> satisfiable by symfony/http-client[v5.1.7].
- nunomaduro/phpinsights is locked to version v1.14.0 and an update of this package was not requested.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
The -W option is the one I'm trying out already. I have tried both -w and -W, no luck so far.
I'm not sure how to get around this problem yet, your input your be very helpful.
Link to .travis.yml
https://github.com/AOEpeople/crawler/blob/master/.travis.yml#L50
Link to Travis Build where testing it out.
https://travis-ci.org/github/AOEpeople/crawler/jobs/738603105#L1138
The issue with composer require was reported and fixed in PR 9336 on Composer's GitHub repository. It will be in Composer 2.0.2 just about to be released now. So you can upgrade to 2.0.2 and it should resolve your problem.
To explain why your workaround failed:
composer require nimut/typo3-complete:$TYPO3_VERSION edits the composer.json file to add "nimut/typo3-complete": "^$TYPO3_VERSION". Then it runs composer update nimut/typo3-complete, or (on Composer 1.x or 2.0.2+) a plain composer update if no lock file exists yet.
If you run a composer install without a lock file first, this executes a composer update because there is no lock file. The subsequent composer require then still edits the json file and now runs composer update nimut/typo3-complete because there is a lock file. Even with all the dependency options enabled, this may have a different outcome or even a conflict from running a plain composer update as you are restricting the update to only the new package and its dependencies.

installing a laravel package using composer without updating dependencies [duplicate]

This question already has answers here:
Composer: how can I install another dependency without updating old ones?
(5 answers)
Closed 2 years ago.
I want to install zizaco/entrust package in laravel 5.8, in their github page it was said to include "zizaco/entrust": "5.2.x-dev" in composer.json file and run composer update command. I did so as below and ran composer update command.
"require" : {
"php" : "^7.1.3",
"fideloper/proxy" : "^4.0",
"laravel/framework" : "5.8.*",
"laravel/tinker" : "^1.0",
"laravel/ui" : "^1.2",
"maatwebsite/excel" : "^3.1",
"zizaco/entrust" : "5.2.x-dev"
},
but composer update command updates all packages to latest versions (these packages i included in "require" field as above) when installing zizaco/entrust package. So is if there are some coding faults in latest updated packages then whole site can break. FYI after i run the above command i see local git showing changes in many files in folders under vendor folder, it means that there are some updates in packages right?. so it's recommended that composer install command should be run so that those dependency packages will not be updated to latest versions.
So, in my case after including "zizaco/entrust": "5.2.x-dev" in require field in composer.json as above, if i run composer install then it don't install zizaco/entrust package. Furthermore, if i run composer require zizaco/entrust 5.2.x-dev then it still installs latest versions of dependency packages.
So how do i prevent installing latest versions of dependency packages i included in "require" field in composer.json file and i only install zizaco/entrust package.
So that my laravel 5.8 site don't break for updating any packages to latest versions because of malfunction codes or whatever in latest versions. It's very important to handle this scenario because we need to install packages in laravel site for various needs.
You've got two options: use composer require to specify the package to install, or manually update your composer.json file and use composer update [package].
Composer Require
composer require zizaco/entrust:5.2.x-dev
This will automatically update your composer.json file and install the specified version. This will not update any of your other dependencies. While the documentation specifies the package and version should be separated by a colon (:), I tested it with a space and it seemed to work.
Composer Update [package]
composer update zizaco/entrust
If you have manually updated your composer.json file, you will need to run composer update and specify the package to update. If you specify a package to update, only that package will be affected. When you don't specify the package to update, composer will look for updates for all packages.
A Note On Composer Install
composer install will not help you here. If you already have a composer.lock file (which you will since you're just attempting to add a new package), composer install will only look at your composer.lock file and attempt to install everything that is defined there. That means, if you manually update your composer.json file, and run composer install, it will not install the new requirement you specified.
Only when you don't already have a composer.lock file will composer install attempt to resolve dependencies and install them.
Run composer install instead. Alternatively you could use composer require <package name>.
Composer install looks in your composer.lock for exact versions, and only in composer.json for packages that are missing.
Composer update will look in composer.json for version constraint which roughly means "a range of versions". This is why different versions are getting installed.
Step 1:
You just need to add your package to the composer.json file and run the command:
composer install
composer install will check for the new package and install that, besides that it will check for any deprecation in other packages.
Step 2:
You can directly run your command in composer
composer require package/name
For example, if I need to install firebase, run below command from the project root:
composer require firebase/php-jwt
Installing new packages from the terminal automatically adds it into the composer.json file and it does not update previously installed packages.
Hope this helps!!

Setting up php-casperjs with composer

I'm having trouble setting up php-casperjs for my project. I've never used composer before, so I'm not exactly sure what I'm doing wrong.
I got xampp installed on Windows with php version 5.6.12
Here are the steps I completed so far.
Downloaded and installed composer. It launches successfully from the command prompt.
Downloaded php-casperjs and extracted composer.json and src/Casper.php into my project folder C:\xampp\htdocs\test
Navigated to the project folder in the command prompt and ran composer install command which installed 22 packages
Then I ran composer require phpcasperjs/phpcasperjs command and here I ran into problems. I get the following error message
Using version ^1.2 for phpcasperjs/phpcasperjs
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpcasperjs/phpcasperjs No version set (parsed as 1.0.0) is satisfiable by phpcasperjs/phpcasperjs[No version
set (parsed as 1.0.0)] but these conflict with your requirements or
minimum-stability.
Installation failed, reverting ./composer.json to its original
content.
When I run the following php code
use Browser\Casper;
$casper = new Casper();
I get Fatal error: Class 'Browser\Casper' not found in C:\xampp\htdocs\test\test.php on line 3
Step1: Go to you project directory and create a file "composer.json"
codes for composer.json
{
"require": {
"monolog/monolog": "1.0.*"
}
}
Note: You can create you composer.json with your required packages but i just created a simple composer.json file with monolog/monolog package. For your understanding you can follow my steps (this). You can remove the package monolog later on.
Now navigate to the project directory where composer.json file located
Run the following command:
composer require phpcasperjs/phpcasperjs
And you faced the above problem because of wrong or mismatched version of the intended package. Keep in mind that you always can create composer.json with your custom packages and their versions and which will be your package manager. For more detail about composer please visit Link

Discover latest versions of Composer packages when dependencies are locked

Let's say I have a composer.json file with locked dependencies:
{
"require" : {
"zendframework/zendframework" : "2.4.2"
},
"require-dev": {
"phpunit/phpunit": "4.6.6"
}
}
I want to do that because would like to update dependencies manually, so I won't be in a situation where my build fails or other developers experience issues I don't have because Composer installed a different version of the package.
Is there a good way to use Composer to list all newer versions of the locked packages, perhaps something like composer discover, where I get output: zendframework/zendframework is locked at version 2.4.2 (or 2.4.* or whatever), but there are versions 2.5.0, 2.5.1, and 2.6.0 available*?
Is any existing command capable of providing that kind of information?
Basically, I'm more about the newer versions being shown to me, so I can know what dependency to update manually. Committing the composer.lock isn't really the solution because that won't show me what to update (and my composer.json is locked at specific versions, so composer.lock won't differ anyway).
In order to do what you want, commit the composer.lock file and make sure everyone runs composer install to install the deps. This way, everyone has exact the same version/commit of each package.
You can then run composer update to get newer versions. This will update the packages and the composer.lock file, which you can commit and push, so everyone has the same versions again (after they run composer install).
This is not exactly what you are suggesting. But you can run
composer update --dry-run
to see what happens when composer updates your dependencies. This only shows you the latest version a package could be updated to, but not the versions in between:
composer update --dry-run
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating symfony/translation (v2.5.5) to symfony/translation (v2.5.11)
- Updating symfony/security-core (v2.5.5) to symfony/security-core (v2.5.11)
- Updating symfony/routing (v2.5.5) to symfony/routing (v2.5.11)
- Updating symfony/process (v2.5.5) to symfony/process (v2.5.11)
- Updating symfony/http-foundation (v2.5.5) to symfony/http-foundation (v2.5.11)
The simplest way would probably just to run:
composer outdated
and get a list of the outdated dependencies. The output looks roughly like this:
As has been said by others, composer does what you tell it, and will only install the versions specified from the .lock file, or update to new versions (as specified within the range of the given version).
There are outside website services that will let you know that packages have been updated though - such as Versioneye.com. You can follow a number of packages, and it will let you know when any of them have been updated, so you can update the composer file as you wish.
To show the latest version of the packages, use show with -l/--latest parameter, e.g.
composer show -l
-l, --latest Show the latest version
To see the tree of dependencies, use -t/--tree parameter, e.g.
composer show -t
-t, --tree List the dependencies as a tree
To list all available version for the given package, run:
composer show -a zendframework/zendframework
Note: Change zendframework/zendframework with your package name.
Notes:
For global, add global right after composer.
For help, run: composer global help show.

Categories