silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
722 stars 821 forks source link

Define PHP version using console variable #10207

Open a2nt opened 2 years ago

a2nt commented 2 years ago

Description

When you run sake it automatically search for php binary candidate, but it can be different than webserver running binary. I suggest to allow defining php binary using console variable.

For example: export SAKE_PHP="/usr/bin/php74"

lerni commented 2 years ago

You can use something like below to achieve the same? {{bin/php}} ./vendor/silverstripe/framework/cli-script.php dev/build "flush=1"

wernerkrauss commented 2 years ago

@lerni sure, but running "sake" might be an easier command e.g. in tutorials.

LiamKearn commented 2 years ago

I think this could be really neat. I think a lot of people that are doing {{bin/php}} ./vendor/silverstripe/framework/cli-script.php dev/build "flush=1" manually in development would appreciate this.

Adding onto what Lerni said another but maybe not as accessible option is update-alternatives(1) or just manually changing what which will resolve to.

maxime-rainville commented 2 years ago

If your environment doesn't have the correct version of PHP, I suspect composer will also give you problem. This seems like a very marginal use case. And there's a lot of other - and probably better ways - of achieving this:

My instinct would be to not do this.

a2nt commented 2 years ago

If your environment doesn't have the correct version of PHP, I suspect composer will also give you problem. This seems like a very marginal use case. And there's a lot of other - and probably better ways - of achieving this:

  • aliasing the php command to point to your preferred version
  • editing your path
  • calling cli-script.php directly

My instinct would be to not do this.

The issue often happens at cPanel hosting with multiply versions of PHP.

Composer utility works smarter for example: ea-php74 /opt/cpanel/composer/bin/composer update

If sake will be able to work the same way it will be awesome

dhensby commented 2 years ago

If sake was written in PHP instead of bash, then the same approach composer uses would be possible

LiamKearn commented 2 years ago

If your environment doesn't have the correct version of PHP, I suspect composer will also give you problem. This seems like a very marginal use case. And there's a lot of other - and probably better ways - of achieving this:

  • aliasing the php command to point to your preferred version
  • editing your path
  • calling cli-script.php directly

My instinct would be to not do this.

The issue often happens at cPanel hosting with multiply versions of PHP.

Composer utility works smarter for example: ea-php74 /opt/cpanel/composer/bin/composer update

If sake will be able to work the same way it will be awesome

Don’t use cPanel for SS but checkout the ‘—ea-reference-dir’ flag if you use ea and not suphp