How to change dev-master releases to stable composer - laravel

I am creating a sockets package in PHP for Laravel, but I can not just use the composer require because the package is in dev-master and of course I do not want to change my entire main application to accept packages in dev-master. Could someone help me make a release stable discoverable by packagist?

Related

Update Magento2 version 2.4.2 to 2.4.3 problem

i am trying to update Magento with the following steps
composer require magento/product-enterprise-edition=2.4.3 --no-update on composer.json archive.
run composer update
And i have these problems
Problem 1
- magento/project-enterprise-edition is present at version 2.4.2 and cannot be modified by Composer
- magento/product-enterprise-edition 2.4.3 requires vertexinc/product-magento-module-commerce 4.2.1 -> satisfiable by vertexinc/product-magento-module-commerce[4.2.1].
- vertexinc/product-magento-module-commerce[4.2.1] cannot be installed as that would require removing magento/project-enterprise-edition[2.4.2]. They both replace vertex/product-magento-module-commerce and thus cannot coexist.
- Root composer.json requires magento/product-enterprise-edition 2.4.3 -> satisfiable by magento/product-enterprise-edition[2.4.3].
Any idea how to solve this problem?
Thanks!
On first glance I'd say that while you do the composer require --no-update [--] magento/product-enterprise-edition=2.4.3 explicitly not doing any updates, the original Magento Enterprise Edition is kept locked to version 2.4.2.
Then running composer update is not updating it, resulting into the foremost problem reported (it looks leading to me, that all other problems are caused by it):
magento/project-enterprise-edition is present at version 2.4.2 and cannot be modified by Composer
It is my own understanding that the reason it cannot be modified by Composer is because magento/project-enterprise-edition is locked to 2.4.2.
Try running:
composer update magento/project-enterprise-edition
to update that package explicitly.
(I can't say - as you did not share in your question - why you did run the composer require with --no-update, it is just that with --no-update the lock file is not updated and it seems that it is in use and further on pinning magento/project-enterprise-edition to [previous!] version 2.4.2 - you want to update to 2.4.3 [!]).
Additionally, running
composer update --with-dependencies magento/project-enterprise-edition or
composer update --with-all-dependencies magento/project-enterprise-edition
may be useful to escalate follow-up issues to make the dependency update command more binding. Excerpt from composer update --help (Composer version 2.1.11 2021-11-02 12:10:2):
-w, --update-with-dependencies: Allows inherited dependencies to be updated, except those that are root requirements.
-W, --update-with-all-dependencies: Allows all inherited dependencies to be updated, including those that are root requirements.
Root requirements are those in your composer.{json,lock} file.

Adding Composer as Manager of Drupal 8

I installed D8 manually but I need Composer to Manage and Install Drush and Drupal Console.
I found docs about fresh install, but I would to know if it's possible to add Composer as Drupal components manager after a manual druapl install ?
Actually I have Composer and Drush9 installed. But I can't do update for D8 because Composer doesn't find infos about this:
~/www/mgasquet/sited8 $ composer outdated
behat/mink-selenium2-driver dev-master 93474c6 dev-master 3ab9f31 Selenium2 (WebDriver) driver for Mink framework
brumann/polyfill-unserialize v1.0.3 v1.0.4 Backports unserialize options introduced in PHP 7.0 to older PHP versions.
composer/installers v1.6.0 v1.7.0 A multi-framework Composer library installer
dflydev/dot-access-data v1.1.0 v2.0.0 Given a deep data structure, access data by dot notation.
doctrine/annotations v1.2.7 v1.7.0 Docblock Annotations Parser
doctrine/cache v1.6.2 v1.8.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 v1.6.2 Collections Abstraction library
doctrine/common v2.6.2 v2.10.0 Common Library for Doctrine projects
doctrine/inflector v1.1.0 v1.3.0 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 1.2.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 1.1.0 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
drupal/coder 8.3.1 8.3.6 Coder is a library to review Drupal code.
egulias/email-validator 2.1.7 2.1.11 A library for validating emails against several RFCs
grasmash/yaml-expander 1.4.0 2.0.0 Expands internal property references in a yaml file.
Thanks for tips.
EDIT: is this a good and actual way ? tuto
EDIT2: as I must update modules too, I face off a little issue ragarding "minimum-stability" , I put this in my composer.json,
"minimum-stability": "dev",
"prefer-stable": true,
But it replace dev version by alpha ones. I prefer using dev or stable not alpha or beta, RC admitted. How can I do that ?
EDIT3: modules aren't downloaded in modules/contrib, so do I need to add this to my composer.json ?
"extra": {
"installer-paths": {
"modules/contrib/{$name}/": ["type:drupal-module"],
"themes/contrib/{$name}/": ["type:drupal-theme"]
},
You can definitely attempt the recommendations on the guide you linked to. Take a full code, database, and file backup of the site first.
That said, I highly recommend you re-build the site using drupal-project. After which:
run composer require for all of your contributed modules / themes
copy any custom modules / themes
re-import the database
copy over your files directory
P.S. to anyone viewing this answer in the future please check the core strategic initiative for up to date info.

Is there a way to composer require without actually pulling the package?

Is there a way to composer require some/thing without actually pulling the package? In my workflow, it would hasten things if I knew a command to just check version requirements and update composer.json without actually doing anything with regard to the vendor directory.
You can use --no-update switch to avoid updating and installing new dependencies - it will only add new dependency to composer.json.
composer require --no-update symfony/symfony
But since require does not check if required package can be installed (it always pick the newest version compatible with your PHP as a constraint, without checking if it will be possible to install), this can leave composer.json in non-installable state.
It will also not update composer.lock so composer install may ignore your new dependency. So this is probably a bad idea unless you want to do something with it before you commit new composer.json.
You may try to use --dry-run switch to test what will happen after composer update - you will be able to check if composer.json is installable, but composer.lock still will be out of date.
composer update --dry-run

Cannot update project with composer

I pushed my package medyes/ebay-api on github.
When I tried to download it on another project with composer I have an error:
Command composer:
composer require medyes/ebay-api:dev-master
The error:
[InvalidArgumentException]
Could not find package medyes/ebay-api at any version for your
minimum-stability (dev). Check the package spelling or your minimum
-stability
this is the composer.json of medyes/ebay-api package
composer.json
Avoid using branches - especially when the project you are about to include offers tagged versions.
composer require medyes/ebay-api:~0.1
This will update this package until version 1.0 comes out (which would not be installed, because that major release number change it is considered incompatible according to semantic versioning) every time a newer, installable version exists and you run composer update.

Composer: how can I install another dependency without updating old ones?

I have a project with a few dependencies and I'd like to install another one, but I'd like to keep the others the way they are. So I've edited the composer.json, but if I run composer install, I get the following output:
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework dev-master requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- laravel/framework dev-master requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- Installation request for laravel/framework dev-master -> satisfiable by laravel/framework dev-master.
First of all, I do have mcrypt installed, so I don't know why it's complaining about that there.
So, how can I install this new dependency?
My composer.json:
{
"require": {
"opauth/opauth": "*",
"opauth/facebook": "*",
"opauth/google": "*",
"opauth/twitter": "*",
"imagine/Imagine": "dev-develop",
"laravel/framework": "4.*",
"loic-sharma/profiler": "dev-master"
},
"autoload": {
"classmap": [
"app/libraries",
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/tests/TestCase.php"
]
},
"minimum-stability": "dev"
}
To install a new package and only that, you have two options:
Using the require command, just run:
composer require new/package
Composer will guess the best version constraint to use, install the package, and add it to composer.lock.
You can also specify an explicit version constraint by running:
composer require new/package ~2.5
–OR–
Using the update command, add the new package manually to composer.json, then run:
composer update new/package
If Composer complains, stating "Your requirements could not be resolved to an installable set of packages.", you can resolve this by passing the flag --with-dependencies. This will whitelist all dependencies of the package you are trying to install/update (but none of your other dependencies).
Regarding the question asker's issues with Laravel and mcrypt: check that it's properly enabled in your CLI php.ini. If php -m doesn't list mcrypt then it's missing.
Important: Don't forget to specify new/package when using composer update! Omitting that argument will cause all dependencies, as well as composer.lock, to be updated.
Actually, the correct solution is:
composer require vendor/package
Taken from the CLI documentation for Composer:
The require command adds new packages to the composer.json file from the current directory.
php composer.phar require
After adding/changing the requirements, the modified requirements will be installed or updated.
If you do not want to choose requirements interactively, you can just pass them to the command.
php composer.phar require vendor/package:2.* vendor/package2:dev-master
While it is true that composer update installs new packages found in composer.json, it will also update the composer.lock file and any installed packages according to any fuzzy logic (> or * chars after the colons) found in composer.json! This can be avoided by using composer update vendor/package, but I wouldn't recommend making a habit of it, as you're one forgotten argument away from a potentially broken project…
Keep things sane and stick with composer require vendor/package for adding new dependencies! 😉
We can install a new package without updating other dependencies like this:
composer require package/name --no-update
this will add your package to composer.json (no update to composer.lock)
composer update package/name
this will now install/update your new package, adding it to composer.lock without updating other deps
My use case is simpler, and fits simply your title but not your further detail.
That is, I want to install a new package which is not yet in my composer.json without updating all the other packages.
The solution here is composer require x/y
In my case, I had a repo with:
requirements A,B,C,D in .json
but only A,B,C in the .lock
In the meantime, A,B,C had newer versions with respect when the lock was generated.
For some reason, I deleted the "vendors" and wanted to do a composer install and failed with the message:
Warning: The lock file is not up to date with the latest changes in composer.json.
You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
I tried to run the solution from Seldaek issuing a composer update vendorD/libraryD but composer insisted to update more things, so .lock had too changes seen my my git tool.
The solution I used was:
Delete all the vendors dir.
Temporarily remove the requirement VendorD/LibraryD from the .json.
run composer install.
Then delete the file .json and checkout it again from the repo (equivalent to re-adding the file, but avoiding potential whitespace changes).
Then run Seldaek's solution composer update vendorD/libraryD
It did install the library, but in addition, git diff showed me that in the .lock only the new things were added without editing the other ones.
(Thnx Seldaek for the pointer ;) )

Resources