asdf-php icon indicating copy to clipboard operation
asdf-php copied to clipboard

Rewrite to be based on php-build

Open smorimoto opened this issue 3 years ago • 17 comments

There is no benefit on our side to managing this too complex shell nightmare, and it should be managed centrally if possible.

smorimoto avatar Jan 23 '21 01:01 smorimoto

Better yet, why not install php precompiled? That would make the plugin so much easier to use (no need to install build dependencies and wait for php to compile etc.)

Side rant: I can't believe it's 2021 and we still haven't shaken this "compile everything" idea in general oss. Right now, right this very second, there's millions of compiles of the same thing happening all over the world.

moljac024 avatar Jan 30 '21 08:01 moljac024

I don't mind. PR is always welcome.

smorimoto avatar Feb 01 '21 10:02 smorimoto

Perhaps supporting both initially is the way to go. How about we transition to php-build but we cache the builds of individual versions somewhere online? So when someone wants to install a specific version, we:

  • Check if we have the build for this architecture cached already and if we do, just pull that and be done
  • If we don't have it cached, do the build via php-build and upload the artifacts to the build cache for the next person to benefit

Then the obvious question is, where can we host the builds for free?

What do you think?

moljac024 avatar Feb 01 '21 10:02 moljac024

The biggest issue is how to distribute the cache as you mentioned. Also, I'm not really familiar with PHP, but are they really relocatable? At this point, I don't have a clear ETA for php-build migration, so if you want to work on it, I recommend that you start by migrating to it first.

smorimoto avatar Feb 03 '21 12:02 smorimoto

Sadly I'm not familiar with PHP either. My only contribution was the comment about avoiding compilation if possible but in retrospect it's not really useful.

moljac024 avatar Feb 11 '21 17:02 moljac024

In fact, there is no incentive to host the cache at all, and implementing something to make sure the cache is safe is quite a hassle. And we need to minimize the dependencies that it requires, and I don't want to do that. I won't stop if someone does it in another plugin, but I absolutely don't want to distribute third-party caches to users through this plugin.

smorimoto avatar Mar 08 '21 21:03 smorimoto

I looked into this a bit. IMHO this codebase is way better organized, and actually supports a greater set of options than php-build. I'd vote for not moving over to use php-build.

iloveitaly avatar Apr 23 '21 17:04 iloveitaly

The advantage of using php-build is that it can support more versions. Our current code only targets the latest version and does not support older versions. (There are some versions that can be built, but we can't say that they are officially supported.)

smorimoto avatar Apr 23 '21 18:04 smorimoto

True, although there are some tradeoffs to consider. The downside is there are a lot of compilation options which are not supported in php-build (--with-gmp for instance). For me, this would be really problematic. Additionally, php-build doesn't seem to fix into the asdf super cleanly (the default assumption is you are using phpenv, although there could be an easy way around that.

We could expand the PHP version matrix in this github workflow to cover more PHP versions, although we still wouldn't have the larger test suite available to us and there would still be duplicated efforts.

iloveitaly avatar Apr 23 '21 20:04 iloveitaly

The downside is there are a lot of compilation options which are not supported in php-build (--with-gmp for instance).

I don't think so: https://github.com/php-build/php-build/blob/master/man/php-build.1.ronn#environment

smorimoto avatar Apr 26 '21 18:04 smorimoto

Another option: https://github.com/shivammathur/homebrew-php + https://github.com/shivammathur/homebrew-extensions

b1rdex avatar Mar 22 '22 12:03 b1rdex

Somehow I had to come back to the PHP world. I've read some PR, but I'm sure what we need now is to rewrite the php-build based plugin. Does anyone want to tackle it?

smorimoto avatar Jul 01 '22 02:07 smorimoto

Better yet, why not install php precompiled? That would make the plugin so much easier to use (no need to install build dependencies and wait for php to compile etc.)

Side rant: I can't believe it's 2021 and we still haven't shaken this "compile everything" idea in general oss. Right now, right this very second, there's millions of compiles of the same thing happening all over the world.

If you want to provide precompiled PHP, you have to also provide precompiled versions of many libraries used by PHP, for example OpenSSL, icu and others since PHP depends on them and user's system can have variety of versions (especially major versions).

tarik02 avatar Sep 27 '22 11:09 tarik02

There are currently not enough main maintainers for this plugin, so it would be nice if someone could do it. Furthermore, if anyone would like to replace this with a php-build-based implementation, I'd be happy to help.

smorimoto avatar Sep 28 '22 01:09 smorimoto

There are currently not enough main maintainers for this plugin, so it would be nice if someone could do it. Furthermore, if anyone would like to replace this with a php-build-based implementation, I'd be happy to help.

I did some investigation, I still have CI broken for example (https://github.com/Tarik02/asdf-php). However this works for my local machine (Arch) it does not work on latest ubuntu machines. As I discovered, the problem is that ubuntu includes libxml which itself uses libicu (which I built together with php) of different version.

So, now I see the only approach is to build most of dependencies before building PHP and use them, e.g. whole prefix with dependencies for it. I'm gonna do more investigation about this.

For arch, it builds (assuming you have the needed dependencies) most verions like 5.6.40, 7.0.33, 7.1.33, 7.4, 8.1.10 and they work as expected. But for ubuntu it's completely broken.

tarik02 avatar Sep 28 '22 07:09 tarik02

Ok so, I just read this thread after mentioning you elsewhere @smorimoto. I think moving to php-build make sense as that is actively maintained and will drastically reduce the amount of maintenance required to keep this up to date.

As far as @moljac024's argument against building from source: I understand the frustration but the alternative requires quite a bit of work to streamline. Either way you go about it, it comes with it's own downsides. At least building from source keeps things relatively straight forward as most operating systems have or had access to the dependencies at some point in time.

99linesofcode avatar Feb 16 '23 13:02 99linesofcode

there are a lot of deprecated packages required by php <= 7. No easy way to work with them.

a21ns1g4ts avatar Mar 23 '23 21:03 a21ns1g4ts