Should extension shims be avoided in Composer? - composer-php

Let's say I have some code in a package that requires ext-oauth to handle OAuth signature generation.
{
"name":"vendor/my-package",
"type":"library",
"require":{
"ext-oauth":"*"
}
}
When I try to install this package on a system that doesn't have the extension, Composer raises an error, as expected.
$ composer install
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 PHP extension ext-oauth * is missing from your system. Install or enable PHP's oauth extension.
Clearly the ext-oauth package is missing on this system, checking via composer show --platform confirms this.
Assume the system can't be updated to include the extension, virtualization (via Docker or Vagrant) also isn't an option. Would hacking around it by using a package that provides the ext-oauth extension or require'ng a package from packagist be a reasonable solution?
This synthetic test appears to work.
{
"name":"vendor/my-package",
"type":"library",
"require":{
"vendor/ext-oauth":"1.0",
"ext-oauth":"*"
},
"repositories":[
{
"type":"package",
"package":{
"name":"vendor/ext-oauth",
"version":"1.0",
"dist":{
"url":"https://example.com/ext-oauth.zip",
"type":"zip"
},
"provide":{
"ext-oauth":"1.0"
},
"autoload":[
"files":[
"src/oauth.php",
"src/oauthexception.php"
]
]
}
}
]
}
Composer then downloads the provided shim and installs it, marking the ext-oauth dependency as met.
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing vendor/ext-oauth (1.0): Downloading (100%)
Writing lock file
Generating autoload files
This feels wrong, but appears to accomplish satisfying the dependency in a maintainable way. Is there a good reason - other than code smell - to avoid providing this sort of shim when PHP extensions can't be installed?

Related

how can i fix this package installation error and install require hardevine/shoppingcart for my laravel project

PS F:\web\Laravel-Advance-Ecommerce-master>
PS F:\web\Laravel-Advance-Ecommerce-master>
PS F:\web\Laravel-Advance-Ecommerce-master> composer require hardevine/shoppingcart
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^3.1 for hardevine/shoppingcart
./composer.json has been updated
Running composer update hardevine/shoppingcart
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\CanBeBought" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\CanBeBought.php" and "F:/web/Laravel-Advance-Ecommerce-master/vendor/hardevine/shoppingcart/src\CanBeBought.php", the first will be used.
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\Cart" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\Cart.php" and "F:/web/Laravel-Advance-Ecommerce-master/vendor/hardevine/shoppingcart/src\Cart.php", the first will be used.
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\CartItem" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\CartItem.php" and "F:/web/Laravel-Advance-Ecommerce-master/vendor/hardevine/shoppingcart/src\CartItem.php", the first will be used.
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\CartItemOptions" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\CartItemOptions.php" and "F:/web/Laravel-Advance-Ecommerce-master/vendor/hardevine/shoppingcart/src\CartItemOptions.php", the first will be used.
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\Contracts\Buyable" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\Contracts\Buyable.php" and "F:/web/Laravel-Advance-Ecommerce-master/vendor/hardevine/shoppingcart/src\Contracts\Buyable.php", the first will be used.
Warning: Ambiguous class resolution, "Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException" was found in both "F:/web/Laravel-Advance-Ecommerce-master/vendor/bumbummen99/shoppingcart/src\Exceptions\CartAlrDiscovered Package: laravel/tinker
Discovered Package: livewire/livewireDiscovered Package: nesbot/carbon
Discovered Package: nunomaduro/collisionDiscovered Package: sven/artisan-view
Package manifest generated successfully.84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!Found 11 security vulnerability advisories affecting 4 packages.
Run composer audit for a full list of advisories.
PS F:\web\Laravel-Advance-Ecommerce-master>
im trying to install this package and create shopping cart for my laravel project
the package you're trying to install hardevine/shoppingcart and the package that already exists in your installation bumbummen99/LaravelShoppingcart are both a fork of the same original package Crinsane/LaravelShoppingcart which is not compatible with the latest version of laravel. You can only use one of them.
Or if you have the patience, make your own fork that merges the functionalities of both forks or just use bumbummen99's which is the most up to date one. Depends on your needs and what those packages add to the original one.

Error installing Openmage (Undefined index: process)

Friends, I am trying to install Openmage and getting the following error:
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 2 installs, 0 updates, 0 removals
- Downloading aoepeople/composer-installers (v0.0.4)
- Installing aoepeople/composer-installers (v0.0.4): Extracting archive
Install of aoepeople/composer-installers failed
[ErrorException]
Undefined index: process
Have you ever exeperienced such an error? My composer version is 2.0.6 and the PHP versIon is 7.3.27.This is how my composer.json looks like in case you guys want to take a look at it:
{
"require": {
"aoepeople/composer-installers": "*",
"openmage/magento-lts": "19.4.6"
}
}
Any idea how could I solve this problem?
Friends,
I have just found a solution: the function "proc_open" was disabled in mys php.ini. Changing this solved my problem.

Can't install module using composer on Magento 2.1

I am trying to install M2ePro module on my Magento ver. 2.1.8 application using composer and getting this error:
[http]$ php-7.0 /usr/local/bin/composer require m2e/ebay-amazon-magento2
Could not find a matching version of package m2e/ebay-amazon-magento2.
Check the package spelling, your version constraint and that the
package is available in a stability which matches your
minimum-stability (alpha).
The spelling of the package is correct, I have tried defining the version of the module (The only one available is 1.3.2):
[http]$ php-7.0 /usr/local/bin/composer require m2e/ebay-amazon-magento2:1.3.2
However get the same error so I believe stability of this module is "Beta" and I have "minimum-stability (alpha)" set so beta modules should be installed with no problems.?
I looked for solution in composer docs but could find anything about installing beta: https://getcomposer.org/doc/03-cli.md#require
Or was I looking in the wrong place?
I managed to successfully install the module on my development site and didn't receive this error so I thought it might be due to the fact that my Magento application was in the "Production" mode but setting the mode to "Developer" did not solve my problem.
UPDATE:
I just found this thread: https://magento.stackexchange.com/questions/114393/error-in-using-composer-to-install-a-module-in-magento-2-0. The answer to this question is that you need to define the package as repository. The package is from marketplace and this is content of my composer.json:
"minimum-stability": "alpha",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
I have previously installed modules from marketplace using composer with no problems.
It came out that my auth.json had incorrect credentials and couldn't find the account.
Correcting the account settings fixed my problem.

Why I cannot install my composer new package?

The package - https://packagist.org/packages/drakonli/php-utils
My composer:
{
"require": {
"php": ">=5.3.0",
"drakonli/php-utils": "dev-master"
},
"minimum-stability": "dev"
}
The error I get when i use "composer install"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package drakonli/php-utils could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
I have added a tag to this package, so it should not be the problem with stability of version.
What I also tried - I tried to search for my package on packagist AND using command composer search. And this is what I got:
When I try to search for "drakonli/" - I CAN find my package, but when I try to search for "drakonli/php-utils" or "php-utils" I CAN'T find my package.
Help, pls.
UPDATE
I was wrong - the package is found but it's on the 1608 page after packages that don't even have "php" or anything in it's name. Even when using the package full name.
UPDATE #2
composer search drakonli
result:
drakonli/php-utils PHP lib of different utility interfaces/classes
AND
composer info drakonli/php-utils
result:
[InvalidArgumentException]
Package drakonli/php-utils not found
Losing my mind here :D
After about 12 hours it fixed on it's own...

Composer: Your requirements could not be resolved to an installable set of packages

I am trying to install a composer package and I continuously get the following error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package rondobley/extended-respect-validation could not be found in any version, there may be a typo in the package name.
Here is the composer.json
{
"minimum-stability": "dev",
"require": {
"rondobley/extended-respect-validation": "^1.0"
}
}
And the output from composer install -vvv:
vagrant#wheezy:/code/test$ composer install -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/code/test): git branch --no-color --no-abbrev -v
Executing command (/code/test): git describe --exact-match --tags
Executing command (/code/test): git log --pretty="%H" -n1 HEAD
Failed to initialize global composer: Composer could not find the config file: /home/vagrant/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.2.0 (2016-07-19 01:28:52) with PHP 5.5.38-1~dotdeb+7.1 on Linux / 3.2.0-4-amd64
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /home/vagrant/.composer/cache/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2013.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2014.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2015.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2015-10.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-01.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-04.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-07.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-archived.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-latest.json from cache
Resolving dependencies through SAT
Dependency resolution completed in 0.001 seconds
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package rondobley/extended-respect-validation could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
The package seems to be fine to me:
https://packagist.org/packages/rondobley/extended-respect-validation
It is a new package, just published today, but it has been several hours. I have also tried composer clearcache and that does not help. I have read many of the other similar issues here with no luck. I am new to publishing composer packages, so maybe I an missing a simple step?
Ideally I would like to install version ^1.0.
Thanks for the help in advance.
See https://twitter.com/packagist/status/772034610632990720 - it was a temporary failure on packagist

Resources