Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Composer replace ext test cases
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": {
"ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
},
"config": {
"platform": {
"php": "5.6"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": {
"ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
},
"config": {
"platform": {
"php": "5.6",
"ext-mongo": "1.6.12"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": {
"ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"ext-mongo": "1.6.12"
},
"config": {
"platform": {
"php": "5.6"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": {
"ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"ext-mongo": "1.6.12"
},
"config": {
"platform": {
"php": "5.6",
"ext-mongo": "1.6.12"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
},
"config": {
"platform": {
"php": "5.6"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
},
"config": {
"platform": {
"php": "5.6",
"ext-mongo": "1.6.12"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"ext-mongo": "1.6.12"
},
"config": {
"platform": {
"php": "5.6"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"ext-hash": "*",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"ext-mongo": "^1.5",
"php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"ext-mongo": "1.6.12"
},
"config": {
"platform": {
"php": "5.6",
"ext-mongo": "1.6.12"
}
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "my-custom-sys/php",
"version": "5.6.18",
"replace": {
"my-custom-sys/ext-hash": "self.version"
}
},
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"my-custom-sys/ext-hash": "*",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": {
"my-custom-sys/ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"my-custom-sys/ext-mongo": "^1.5",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "my-custom-sys/php",
"version": "5.6.18",
"replace": {
"my-custom-sys/ext-hash": "self.version"
}
},
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"my-custom-sys/ext-hash": "*",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": {
"my-custom-sys/ext-mongo": "1.6.12"
},
"provide": [],
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"my-custom-sys/ext-mongo": "^1.5",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"my-custom-sys/ext-mongo": "1.6.12"
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "my-custom-sys/php",
"version": "5.6.18",
"replace": {
"my-custom-sys/ext-hash": "self.version"
}
},
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"my-custom-sys/ext-hash": "*",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"my-custom-sys/ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"my-custom-sys/ext-mongo": "^1.5",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"doctrine\/mongodb": "dev-master"
}
}
{
"repositories": [
{
"packagist": false
},
{
"type": "package",
"package": [
{
"type": "metapackage",
"name": "my-custom-sys/php",
"version": "5.6.18",
"replace": {
"my-custom-sys/ext-hash": "self.version"
}
},
{
"type": "metapackage",
"name": "alcaeus\/mongo-php-adapter",
"version": "dev-master",
"require": {
"my-custom-sys/ext-hash": "*",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": {
"my-custom-sys/ext-mongo": "1.6.12"
},
"conflict": []
},
{
"type": "metapackage",
"name": "doctrine\/mongodb",
"version": "dev-master",
"require": {
"my-custom-sys/ext-mongo": "^1.5",
"my-custom-sys/php": "^5.5 || ^7.0"
},
"replace": [],
"provide": [],
"conflict": []
}
]
}
],
"require": {
"alcaeus\/mongo-php-adapter": "dev-master",
"my-custom-sys/ext-mongo": "1.6.12"
}
}
@dzuelke

This comment has been minimized.

Copy link
Owner Author

@dzuelke dzuelke commented Feb 23, 2016

  1. git clone https://gist.github.com/4cc18791e439afe99183.git
  2. cd 4cc18791e439afe99183
  3. for f in composer*.json; do echo "$f:"; COMPOSER=$f composer update --dry-run; done
  4. for f in composer*.json; do echo "$f:"; COMPOSER=$f php -n $(which composer) update --dry-run; done
@dzuelke

This comment has been minimized.

Copy link
Owner Author

@dzuelke dzuelke commented Feb 23, 2016

I guess the reason why different people report different results is because some have ext-mongo installed and some haven't. So many permutations :(

@alcaeus

This comment has been minimized.

Copy link

@alcaeus alcaeus commented Feb 23, 2016

From what I can tell, examples 3, 4, 5 and 6 are the ones we actually want. There are two different approaches though:

  1. provide makes the adapter behave like a polyfill, meaning "require this class in case ext-mongo is missing but don't do anything if it's there". This may seem desirable but users may not be aware that the adapter is not being used because ext-mongo is installed.
  2. replace adheres more strictly to the "composer way of life": if ext-mongo is installed the user will be informed that there is a conflict and all is well.

The replace directive would have to be changed to replace all versions of ext-mongo that can be possibly replaced; in this case I'd actually use the following replace in mongo-php-adapter:

"replace": {
    "ext-mongo": ">=1.3.0 || <1.7"
},

Also, the error message that comes up in case ext-mongo is already installed is quite confusing:

  [InvalidArgumentException]                    
  Package is not installed: ext-mongo-1.6.12.0

This can be confusing for users since it may seem that ext-mongo has to be installed when it already is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment