Composer. How to install a specific version of package based on user php version?
up vote
1
down vote
favorite
I have a two version of my package: for php7 and for php5. Is it possible to make composer determine when installing the package which version of php the user has, and depending on this, install the correct version of my package?
php composer-php dependency-management
New contributor
add a comment |
up vote
1
down vote
favorite
I have a two version of my package: for php7 and for php5. Is it possible to make composer determine when installing the package which version of php the user has, and depending on this, install the correct version of my package?
php composer-php dependency-management
New contributor
1
Is the question incomplete? Maybe have twocomposer.json
files. Just telling.
– Praveen Kumar Purushothaman
6 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a two version of my package: for php7 and for php5. Is it possible to make composer determine when installing the package which version of php the user has, and depending on this, install the correct version of my package?
php composer-php dependency-management
New contributor
I have a two version of my package: for php7 and for php5. Is it possible to make composer determine when installing the package which version of php the user has, and depending on this, install the correct version of my package?
php composer-php dependency-management
php composer-php dependency-management
New contributor
New contributor
edited 6 hours ago
New contributor
asked 6 hours ago
Zhalgas Zhamaliev
83
83
New contributor
New contributor
1
Is the question incomplete? Maybe have twocomposer.json
files. Just telling.
– Praveen Kumar Purushothaman
6 hours ago
add a comment |
1
Is the question incomplete? Maybe have twocomposer.json
files. Just telling.
– Praveen Kumar Purushothaman
6 hours ago
1
1
Is the question incomplete? Maybe have two
composer.json
files. Just telling.– Praveen Kumar Purushothaman
6 hours ago
Is the question incomplete? Maybe have two
composer.json
files. Just telling.– Praveen Kumar Purushothaman
6 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
TL;DR: Yes.
By default, composer uses the version of the php executable to determine, which version of the package to install. This can be overridden in the config
section of composer.json, for example:
"config": {
"vendor-dir": "vendor",
"platform": {
"php": "5.6"
}
}
When someone requires your package, this version is compared to the one specified in the requirements list of your package's composer.json:
"require": {
"php": ">=7.2.0",
}
So if, for example, version 1 of your package requires php 5.6, and version 2 requires php 7.0, someone who runs composer require your-package
with php 5.6 will have version 1 installed. If someone runs it with an older version than required by any of your versions, they'll get an error stating that composer could not find a package that satisfies all the requirements, the php version being one of them.
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
add a comment |
up vote
0
down vote
Install only one composer you can access this composer with different php version
/usr/bin/php /usr/local/bin/composer
/usr/bin/php7.1 /usr/local/bin/composer
/usr/bin/php7.0 /usr/local/bin/composer
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
TL;DR: Yes.
By default, composer uses the version of the php executable to determine, which version of the package to install. This can be overridden in the config
section of composer.json, for example:
"config": {
"vendor-dir": "vendor",
"platform": {
"php": "5.6"
}
}
When someone requires your package, this version is compared to the one specified in the requirements list of your package's composer.json:
"require": {
"php": ">=7.2.0",
}
So if, for example, version 1 of your package requires php 5.6, and version 2 requires php 7.0, someone who runs composer require your-package
with php 5.6 will have version 1 installed. If someone runs it with an older version than required by any of your versions, they'll get an error stating that composer could not find a package that satisfies all the requirements, the php version being one of them.
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
add a comment |
up vote
2
down vote
accepted
TL;DR: Yes.
By default, composer uses the version of the php executable to determine, which version of the package to install. This can be overridden in the config
section of composer.json, for example:
"config": {
"vendor-dir": "vendor",
"platform": {
"php": "5.6"
}
}
When someone requires your package, this version is compared to the one specified in the requirements list of your package's composer.json:
"require": {
"php": ">=7.2.0",
}
So if, for example, version 1 of your package requires php 5.6, and version 2 requires php 7.0, someone who runs composer require your-package
with php 5.6 will have version 1 installed. If someone runs it with an older version than required by any of your versions, they'll get an error stating that composer could not find a package that satisfies all the requirements, the php version being one of them.
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
TL;DR: Yes.
By default, composer uses the version of the php executable to determine, which version of the package to install. This can be overridden in the config
section of composer.json, for example:
"config": {
"vendor-dir": "vendor",
"platform": {
"php": "5.6"
}
}
When someone requires your package, this version is compared to the one specified in the requirements list of your package's composer.json:
"require": {
"php": ">=7.2.0",
}
So if, for example, version 1 of your package requires php 5.6, and version 2 requires php 7.0, someone who runs composer require your-package
with php 5.6 will have version 1 installed. If someone runs it with an older version than required by any of your versions, they'll get an error stating that composer could not find a package that satisfies all the requirements, the php version being one of them.
TL;DR: Yes.
By default, composer uses the version of the php executable to determine, which version of the package to install. This can be overridden in the config
section of composer.json, for example:
"config": {
"vendor-dir": "vendor",
"platform": {
"php": "5.6"
}
}
When someone requires your package, this version is compared to the one specified in the requirements list of your package's composer.json:
"require": {
"php": ">=7.2.0",
}
So if, for example, version 1 of your package requires php 5.6, and version 2 requires php 7.0, someone who runs composer require your-package
with php 5.6 will have version 1 installed. If someone runs it with an older version than required by any of your versions, they'll get an error stating that composer could not find a package that satisfies all the requirements, the php version being one of them.
answered 5 hours ago
Bartosz Zasada
2,48521021
2,48521021
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
add a comment |
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
Thank you. Your answer helped me a lot
– Zhalgas Zhamaliev
3 hours ago
add a comment |
up vote
0
down vote
Install only one composer you can access this composer with different php version
/usr/bin/php /usr/local/bin/composer
/usr/bin/php7.1 /usr/local/bin/composer
/usr/bin/php7.0 /usr/local/bin/composer
add a comment |
up vote
0
down vote
Install only one composer you can access this composer with different php version
/usr/bin/php /usr/local/bin/composer
/usr/bin/php7.1 /usr/local/bin/composer
/usr/bin/php7.0 /usr/local/bin/composer
add a comment |
up vote
0
down vote
up vote
0
down vote
Install only one composer you can access this composer with different php version
/usr/bin/php /usr/local/bin/composer
/usr/bin/php7.1 /usr/local/bin/composer
/usr/bin/php7.0 /usr/local/bin/composer
Install only one composer you can access this composer with different php version
/usr/bin/php /usr/local/bin/composer
/usr/bin/php7.1 /usr/local/bin/composer
/usr/bin/php7.0 /usr/local/bin/composer
answered 5 hours ago
Raju Sadadiya
13
13
add a comment |
add a comment |
Zhalgas Zhamaliev is a new contributor. Be nice, and check out our Code of Conduct.
Zhalgas Zhamaliev is a new contributor. Be nice, and check out our Code of Conduct.
Zhalgas Zhamaliev is a new contributor. Be nice, and check out our Code of Conduct.
Zhalgas Zhamaliev is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371333%2fcomposer-how-to-install-a-specific-version-of-package-based-on-user-php-version%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Is the question incomplete? Maybe have two
composer.json
files. Just telling.– Praveen Kumar Purushothaman
6 hours ago